From e5c8ebf6e276f269536cfd7da9e93d25df235634 Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Tue, 19 Jul 2011 11:43:24 -0700 Subject: [PATCH] Add cucumber feature for changing email address --- features/change_email.feature | 14 ++++++++++++++ features/change_password.feature | 2 +- features/step_definitions/user_steps.rb | 11 +++++++++-- 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 features/change_email.feature diff --git a/features/change_email.feature b/features/change_email.feature new file mode 100644 index 000000000..d81f4d0e8 --- /dev/null +++ b/features/change_email.feature @@ -0,0 +1,14 @@ +@javascript +Feature: Change email + + Scenario: Change my email + Given I am signed in + And I click on my name in the header + And I follow "settings" + Then I should be on my account settings page + When I fill in "user_email" with "new_email@newplac.es" + And I press "Change E-Mail" + Then I should see "E-Mail Changed" + And I follow the "confirm_email" link from the last sent email + Then I should see "activated" + And my "email" should be "new_email@newplac.es" diff --git a/features/change_password.feature b/features/change_password.feature index 31da98c01..4a44797b5 100644 --- a/features/change_password.feature +++ b/features/change_password.feature @@ -21,7 +21,7 @@ Feature: Change password And I fill in "Email" with "forgetful@users.net" And I press "Send me reset password instructions" Then I should see "You will receive an email with instructions" - And I follow the "Change my password" link from the Devise.mailer + And I follow the "Change my password" link from the last sent email Then I should see "Change your password" And I fill in "Password" with "supersecret" And I fill in "Password confirmation" with "supersecret" diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index ea13642d0..797ea99e9 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -144,10 +144,13 @@ When /^I post a status with the text "([^\"]*)"$/ do |text| end -And /^I follow the "([^\"]*)" link from the Devise.mailer$/ do |link_text| - doc = Nokogiri(Devise.mailer.deliveries.first.body.to_s) +And /^I follow the "([^\"]*)" link from the last sent email$/ do |link_text| + email_text = Devise.mailer.deliveries.first.body.to_s + email_text = Devise.mailer.deliveries.first.html_part.body.raw_source if email_text.blank? + doc = Nokogiri(email_text) links = doc.css('a') link = links.detect{ |link| link.text == link_text } + link = links.detect{ |link| link.attributes["href"].value.include?(link_text)} unless link path = link.attributes["href"].value visit URI::parse(path).request_uri end @@ -160,3 +163,7 @@ When /^"([^\"]+)" has posted a status message with a photo$/ do |email| user.dispatch_post(p) end end + +Then /^my "([^\"]*)" should be "([^\"]*)"$/ do |field, value| + @me.reload.send(field).should == value +end