Add cucumber feature for changing email address

This commit is contained in:
Raphael Sofaer 2011-07-19 11:43:24 -07:00
parent b01ffb4489
commit e5c8ebf6e2
3 changed files with 24 additions and 3 deletions

View file

@ -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"

View file

@ -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"

View file

@ -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