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

42 lines
1.5 KiB
Ruby

step "I provide a new supplier email address" do
find('#supplier_email').set 'new-supplier-mail@qwaiter.com'
end
step "the supplier submits the supplier settings form" do
find('.submit-supplier-settings').click
end
step "the supplier email should not have been changed" do
@supplier.reload
@supplier.email.should == 'supplier@qwaiter.com'
end
step "the supplier unconfirmed email should have been set to the new supplier email" do
@supplier.reload
@supplier.unconfirmed_email.should == 'new-supplier-mail@qwaiter.com'
end
step "an email should have been sent to the original supplier email with email confirmation instructions" do
mail = ActionMailer::Base.deliveries.last
mail.to.should == ['supplier@qwaiter.com']
mail.body.should include I18n.t('devise.mailer.confirmation_instructions.supplier.salutation', email: @supplier.email)
mail.body.should_not include 'translation' # indicating a translation issue
confirmation_link_match = mail.body.match(/http:\/\/www.qwaiter.com(\/suppliers\/confirmation[^"]+)"/)
confirmation_link_match.should be_present
@confirmation_link = confirmation_link_match[1]
end
step "the supplier clicks on the new email confirmation link" do
visit @confirmation_link
end
step "the supplier gets redirected to the supplier settings path" do
route_should_be 'supplier#edit'
end
step "the supplier email is the new email and the unconfirmed email is empty" do
@supplier.reload
@supplier.email.should == 'new-supplier-mail@qwaiter.com'
@supplier.unconfirmed_email.should be_blank
end