Supplier mail changing and polishing

This commit is contained in:
2013-12-11 16:00:35 +01:00
parent 0ac9a70797
commit 8aede39b27
28 changed files with 207 additions and 72 deletions
@@ -1,2 +1,13 @@
Feature: Manage settings
Scenario: Changing the supplier email
Given there is a confirmed and open supplier
And I am signed in as supplier
When I visit the supplier settings path
And I provide a new supplier email address
And the supplier submits the supplier settings form
Then the supplier email should not have been changed
And the supplier unconfirmed email should have been set to the new supplier email
And an email should have been sent to the original supplier email with email confirmation instructions
When the supplier clicks on the new email confirmation link
Then the supplier gets redirected to the supplier settings path
And the supplier email is the new email and the unconfirmed email is empty
@@ -12,5 +12,10 @@ end
step "I should be redirected to the supplier settings page" do
page.current_path.should == supplier_settings_path
#page.current_path.should == supplier_settings_path
route_should_be 'supplier#edit'
end
step "I visit the supplier settings path" do
visit supplier_settings_path
end
@@ -0,0 +1,41 @@
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