Files
mozo-backend/spec/acceptance_steps/suppliers/settings_steps.rb
T
2015-01-21 19:18:12 +01:00

57 lines
2.0 KiB
Ruby

step "I provide a new supplier email address" do
js_set_field '.supplier-email', 'new-supplier-mail@mozo.bar'
end
step "the supplier submits the supplier settings form" do
find('.submit-supplier-settings').click
sleep 1.5 # give application some time
end
step "the supplier email should not have been changed" do
@supplier.reload
@supplier.email.should == 'supplier@mozo.bar'
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@mozo.bar'
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@mozo.bar']
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.mozo.bar(\/suppliers\/confirmation[^"]+)"/)
confirmation_link_match.should be_present
@confirmation_link = confirmation_link_match[1]
end
step "the supplier changes the name to :name in the settings page" do |new_name|
js_set_field 'input.supplier-name', new_name
end
step "the supplier clicks on the new email confirmation link" do
visit @confirmation_link
end
step "the supplier should be redirected to the supplier settings path" do
# route_should_be 'supplier#edit'
ember_route_should_be '/settings'
end
step "the supplier email is the new email and the unconfirmed email is empty" do
@supplier.reload
@supplier.email.should == 'new-supplier-mail@mozo.bar'
@supplier.unconfirmed_email.should be_blank
end
step "the supplier selects :time_zone as Time Zone" do |visual_time_zone|
page.select visual_time_zone, from: 'supplier_time_zone'
end
step "the supplier timezone should be :time_zone" do |time_zone|
@supplier.reload
@supplier.time_zone.should == time_zone
end