End of day commit

This commit is contained in:
2015-02-18 22:36:47 +01:00
parent 82670f271b
commit c1858455e9
68 changed files with 633 additions and 145 deletions
+16
View File
@@ -0,0 +1,16 @@
require 'spec_helper'
describe Employee do
context 'class methods' do
describe '.count_by_email' do
it 'is zero without employees' do
described_class.count_by_email('admin@example.com').should be_zero
end
it 'is one when an email already exists' do
create :employee, email: 'alreadyexisting@example.com'
described_class.count_by_email('alreadyexisting@example.com').should be 1
end
end
end
end
+26
View File
@@ -103,4 +103,30 @@ describe Supplier do
end
end
describe '#employee_settings' do
let(:employee){ create :employee }
it 'is initialized by default' do
supplier.employee_settings.should be_a SupplierEmployeesSettings
end
it 'returns null object without employee' do
supplier.employee_settings.for_employee('asdf').should_not be_present
end
it 'returns employee_settings on for employee' do
supplier.add_employee employee
settings = supplier.employee_settings.for_employee(employee.id)
settings.should be_present
settings.manager?.should be false
end
it 'indicates a manager when specified as such and is persisted' do
supplier.add_manager employee
settings = supplier.employee_settings.for_employee(employee.id)
settings.manager?.should be true
reloaded_supplier = Supplier.find(supplier.id)
settings = reloaded_supplier.employee_settings.for_employee(employee.id)
settings.manager?.should be true
end
end
end