Skip to content

Instantly share code, notes, and snippets.

@dawidlenkiewicz
dawidlenkiewicz / FogSpec.js
Created January 12, 2015 15:04
Jasmine example
describe("Fog", function() {
var fog;
beforeEach(function() {
fog = new Fog();
});
it("should create Fog with default parameters", function() {
expect(fog.settings.zMinMax).toEqual([ 0, 100 ]);
expect(fog.settings.intensity).toEqual(1);
class EditStatusConstraint
def self.matches?(request)
request.params['update_action'] == 'edit_status'
end
end
patch 'calculations/:id' => 'calculations/edit_status#create', constraints: EditStatusConstraint
= simple_form_for @calculation do |f|
.row
= f.input :status
= hidden_field_tag 'update_action', 'edit_status'
= f.submit
= simple_form_for @calculation do |f|
.row
= f.input :status
= hidden_field_tag 'update_action', 'change_insured_count'
= f.submit
@dawidlenkiewicz
dawidlenkiewicz / client.rb
Created September 16, 2014 09:35
delegate
base.delegate :province_name, to: 'address.zip_code', allow_nil: true
class EmailValidator < ActiveModel::EachValidator
require 'resolv'
def validate_each(record, attribute, value)
unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
record.errors[attribute] << (options[:message] || I18n.t('email.wrong'))
end
split_email = value.split("@")
domain = split_email[1].to_s
search_result: {
['09:00', '10:59']: ['xxx', 'zzz', 'yyy'],
['11:00', '12:59']: ['kkk', 'lll', 'mmm']
...
}
FactoryGirl.define do
factory :client_person do
first_name "Joe"
sequence(:last_name) { |n| "Doe#{n}" }
pesel { Rpg::Pesel.new(gender: :female, date: Time.at(0.0 + rand * (Time.now.to_f - 0.0.to_f)).strftime('%Y-%m-%d')).generate }
end
end
FactoryGirl.define do
factory :client_person do
first_name "Joe"
sequence(:last_name) { |n| "Doe#{n}" }
pesel { Pesel::EXAMPLE_Pesels[ClientPerson.count] }
end
end