-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added integration tests of the password reset process #205
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require 'spec_helper' | ||
|
||
feature 'Password reset' do | ||
let(:user) { create(:participant, name: 'Hedy Lamarr', email: '[email protected]') } | ||
|
||
scenario 'The home page has a link to the reset password page' do | ||
visit root_path | ||
assert page.has_link?('Forgot Password?', href: new_password_reset_path) | ||
end | ||
|
||
scenario 'The reset password page has the expected content' do | ||
visit new_password_reset_path | ||
assert page.has_css?('h1', text: 'Reset Password') | ||
assert page.has_text?('Please enter your email address below') | ||
end | ||
|
||
scenario 'Participant can reset password' do | ||
# Event needed until Pull Request #202 is merged into the code base | ||
Event.create!(name: 'Event 1', date: Time.now) | ||
|
||
# Enter an invalid email address | ||
visit new_password_reset_path | ||
fill_in 'email', with: '[email protected]' | ||
click_button 'Reset Password' | ||
assert page.has_text?('No participant was found with email address [email protected]') | ||
|
||
# Enter a valid email address | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd make each one of these individual example blocks. |
||
visit new_password_reset_path | ||
fill_in 'email', with: user.email | ||
click_button 'Reset Password' | ||
assert page.has_text?('Instructions to reset your password have been emailed to you') | ||
|
||
# Open and follow instructions | ||
open_email(user.email) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ohhh I didnt know about this... I like it. |
||
assert current_email.subject.include?('Password Reset Instructions') | ||
assert current_email.body.include?('A request to reset your password has been made.') | ||
current_email.click_link 'Reset Password!' | ||
clear_emails | ||
|
||
# Provide new password | ||
assert page.has_css?('h1', text: 'Update your password') | ||
assert page.has_text?('Please enter the new password below') | ||
fill_in('password', with: 'MN Tech Community') | ||
sleep 4.1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll want to remove this. If you specify a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this is the only substantial change requested. I'd be happy to merge this if we can remove the sleep call. |
||
click_on 'Update Password' | ||
assert page.has_text?('Your password was successfully updated') | ||
click_on 'Log out' | ||
|
||
# Log in under the normal method | ||
visit root_path | ||
click_link "Log in" | ||
fill_in 'Email', with: user.email | ||
fill_in 'Password', with: 'MN Tech Community' | ||
check 'Remember me' | ||
click_button "Log in" | ||
expect(page).to have_content "You're logged in. Welcome back." | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not extract this to a
let
?