Refactored cucumber features, steps, and support helpers for change password feature
This commit is contained in:
parent
0c340d8056
commit
7c4c11f8d6
4 changed files with 60 additions and 11 deletions
|
|
@ -4,9 +4,7 @@ Feature: Change password
|
|||
Scenario: Change my password
|
||||
Given I am signed in
|
||||
When I go to the users edit page
|
||||
And I put in my password in "user_current_password"
|
||||
And I fill in "user_password" with "newsecret"
|
||||
And I fill in "user_password_confirmation" with "newsecret"
|
||||
And I fill out change password section with my password and "newsecret" and "newsecret"
|
||||
And I press "Change password"
|
||||
Then I should see "Password changed"
|
||||
Then I should be on the new user session page
|
||||
|
|
@ -15,13 +13,12 @@ Feature: Change password
|
|||
|
||||
Scenario: Reset my password
|
||||
Given a user with email "forgetful@users.net"
|
||||
Given I am on the new user password page
|
||||
And I fill in "Email" with "Forgetful@users.net"
|
||||
And I press "Send me reset password instructions"
|
||||
Given I am on forgot password page
|
||||
When I fill out forgot password form with "Forgetful@users.net"
|
||||
And I submit forgot password form
|
||||
Then I should see "You will receive an email with instructions"
|
||||
And I follow the "Change my password" link from the last sent email
|
||||
When I follow the "Change my password" link from the last sent email
|
||||
Then I should see "Change my password"
|
||||
And I fill in "Password" with "supersecret"
|
||||
And I fill in "Password confirmation" with "supersecret"
|
||||
And I press "Change my password"
|
||||
Then I should be on the stream page
|
||||
When I fill out reset password form with "supersecret" and "supersecret"
|
||||
And I submit reset password form
|
||||
Then I should be on the stream page
|
||||
|
|
@ -36,6 +36,26 @@ When /^I put in my password in "([^"]*)"$/ do |field|
|
|||
step %(I fill in "#{field}" with "#{@me.password}")
|
||||
end
|
||||
|
||||
When /^I fill out change password section with my password and "([^"]*)" and "([^"]*)"$/ do |new_pass, confirm_pass|
|
||||
fill_change_password_section(@me.password, new_pass, confirm_pass)
|
||||
end
|
||||
|
||||
When /^I fill out forgot password form with "([^"]*)"$/ do |email|
|
||||
fill_forgot_password_form(email)
|
||||
end
|
||||
|
||||
When /^I submit forgot password form$/ do
|
||||
submit_forgot_password_form
|
||||
end
|
||||
|
||||
When /^I fill out reset password form with "([^"]*)" and "([^"]*)"$/ do |new_pass,confirm_pass|
|
||||
fill_reset_password_form(new_pass, confirm_pass)
|
||||
end
|
||||
|
||||
When /^I submit reset password form$/ do
|
||||
submit_reset_password_form
|
||||
end
|
||||
|
||||
When /^I (?:log|sign) out$/ do
|
||||
logout
|
||||
end
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ module NavigationHelpers
|
|||
person_path(@me.person, :ex => true)
|
||||
when /^the new stream$/
|
||||
stream_path(:ex => true)
|
||||
when /^forgot password page$/
|
||||
new_user_password_path
|
||||
when /^"(\/.*)"/
|
||||
$1
|
||||
else
|
||||
|
|
|
|||
|
|
@ -53,10 +53,40 @@ module UserCukeHelpers
|
|||
$browser.delete_all_visible_cookies if $browser
|
||||
end
|
||||
|
||||
# go to user menu, expand it, and click logout
|
||||
def manual_logout
|
||||
find("#user_menu li:first-child a").click
|
||||
find("#user_menu li:last-child a").click
|
||||
end
|
||||
|
||||
# fill change password section on the user edit page
|
||||
def fill_change_password_section(cur_pass, new_pass, confirm_pass)
|
||||
fill_in 'user_current_password', :with => cur_pass
|
||||
fill_in 'user_password', :with => new_pass
|
||||
fill_in 'user_password_confirmation', :with => confirm_pass
|
||||
end
|
||||
|
||||
# fill forgot password form to get reset password link
|
||||
def fill_forgot_password_form(email)
|
||||
fill_in 'user_email', :with => email
|
||||
end
|
||||
|
||||
# submit forgot password form to get reset password link
|
||||
def submit_forgot_password_form
|
||||
find("#new_user input.button").click
|
||||
end
|
||||
|
||||
# fill the reset password form
|
||||
def fill_reset_password_form(new_pass, confirm_pass)
|
||||
fill_in 'user_password', :with => new_pass
|
||||
fill_in 'user_password_confirmation', :with => confirm_pass
|
||||
end
|
||||
|
||||
# submit reset password form
|
||||
def submit_reset_password_form
|
||||
find(".button").click
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
World(UserCukeHelpers)
|
||||
|
|
|
|||
Loading…
Reference in a new issue