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
@@ -1,6 +1,6 @@
step "I am signed in as supplier" do
visit test_login_admin_suppliers_path(email: @supplier.email)
visit test_login_admin_employees_path(email: @employee.email)
#step 'visit the supplier sign in path'
#find('#supplier_email').set @supplier.email
#find('#supplier_password').set @supplier_password
@@ -1,5 +1,7 @@
step 'there is a confirmed and open supplier' do
@supplier_password = 'secret1'
@supplier = create :supplier, email: 'supplier@mozo.bar', password: @supplier_password, confirmation_token: 'abc', confirmed_at: Time.now.utc, open: true
@employee = create :employee, email: 'supplier@mozo.bar', password: @supplier_password, confirmation_token: 'abc', confirmed_at: Time.now.utc
@supplier = build :supplier, open: true
@supplier.add_manager @employee
@section = create :section, title: 'Room', supplier: @supplier, width: 8, height: 8
end
+11
View File
@@ -0,0 +1,11 @@
FactoryGirl.define do
factory :employee do
sequence(:name){|i| "Employee #{i}"}
email 'employee@mozo.bar'
password 'secret'
trait :confirmed do
confirmed_at { Time.now }
end
end
end
-6
View File
@@ -1,12 +1,6 @@
FactoryGirl.define do
factory :supplier do
sequence(:name){|i| "Supplier #{i}"}
email 'supplier@mozo.bar'
password 'secret'
trait :confirmed do
confirmed_at { Time.now }
end
end
end
+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
+6
View File
@@ -0,0 +1,6 @@
require 'spec_helper'
describe NewSupplier do
subject { described_class.new }
it { should_not be_persisted }
end
+8 -8
View File
@@ -1,13 +1,13 @@
module Features
module BasicHelpers
module BasicHelpers
# Put helper methods you need to be available in all acceptance specs here.
def create_user(email, password='secret')
@user = User.find_by_email(email) || FactoryGirl.create(:user, email: email, password: password)
end
def create_supplier(email, password='secret')
@supplier = Supplier.find_by_email(email) || FactoryGirl.create(:supplier, email: email, password: password)
end
#def create_supplier(email, password='secret')
#@supplier = Supplier.find_by_email(email) || FactoryGirl.create(:supplier, email: email, password: password)
#end
def create_confirmed_supplier(email, password='secret')
@supplier = Supplier.find_by_email(email) || FactoryGirl.create(:supplier, :confirmed, email: email, password: password)
@@ -21,10 +21,10 @@ module Features
submit_form
end
def login_supplier_as(email)
visit "/suppliers/sign_in"
fill_in "supplier_email", with: email
fill_in "supplier_password", with: "secret"
def login_employee_as(email)
visit "/employees/sign_in"
fill_in "employee_email", with: email
fill_in "employee_password", with: "secret"
submit_form
end