Files
mozo-backend/spec/acceptance_steps/suppliers/signup_steps.rb
T

62 lines
2.3 KiB
Ruby

step "I visit the supplier signup path" do
visit new_suppliers_path
end
step "fill in the supplier signup form with new credentials" do
js_set_field '#new_supplier_supplier_name', 'Signup Supplier'
js_set_field '#new_supplier_email', 'signup_supplier@example.com'
js_set_field '#new_supplier_password', 'SignupSupplier'
js_set_field '#new_supplier_password_confirmation', 'SignupSupplier'
end
step "fill in the supplier signup form with existing employee credentials" do
js_set_field '#new_supplier_supplier_name', 'Signup Supplier'
js_set_field '#new_supplier_email', @employee.email
js_set_field '#new_supplier_password', @employee_password
js_set_field '#new_supplier_password_confirmation', @employee_password
end
step "fill in the supplier signup form with a new supplier name" do
js_set_field '#new_supplier_supplier_name', 'Signup Supplier'
end
step "click on the supplier signup submit button" do
find('[name="commit"]').click
end
step "a new supplier with the new signup data should be created" do
@signup_supplier = Supplier.find_by_name('Signup Supplier')
@signup_supplier.should be_present
@signup_employee = Employee.find_by_email('signup_supplier@example.com')
@signup_employee.should be_present
@employee_settings = @signup_supplier.settings_for(@signup_employee)
@employee_settings.should be_present
@employee_settings.manager?.should be true
end
step "a new supplier with the existing employee should be created" do
@signup_supplier = Supplier.find_by_name('Signup Supplier')
@signup_supplier.should be_present
Employee.count.should eq 1 # No new employee, but existing
@employee_settings = @signup_supplier.settings_for(@employee)
@employee_settings.should be_present
@employee_settings.manager?.should be true
end
step "a supplier signup confirmation mail should be sent containing a link to the token" do
mail = ActionMailer::Base.deliveries.last
mail.should be_present
mail.body.should match /confirmation_token=\w+/
end
step "I visit the supplier signup confirmation path with the correct token" do
visit supplier_confirmation_path(confirmation_token: @signup_supplier.confirmation_token)
end
step "the new signup supplier should be confirmed" do
@signup_supplier.reload
@signup_supplier.should be_confirmed
end