-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inline email update form into /account
Note there are two fields on this page labelled "Current password" so we have to scope the Capybara selector in the system test more specifically to avoid errors.
- Loading branch information
Showing
10 changed files
with
76 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,21 +8,16 @@ class EmailsControllerTest < ActionDispatch::IntegrationTest | |
@user = log_in_as(create(:user)) | ||
end | ||
|
||
test 'should get edit' do | ||
get edit_identity_email_url | ||
assert_response :success | ||
end | ||
|
||
test 'should update email' do | ||
patch identity_email_url, params: { email: '[email protected]', current_password: 'Secret1*3*5*' } | ||
assert_redirected_to root_url | ||
assert_redirected_to account_path | ||
end | ||
|
||
test 'should not update email with wrong current password' do | ||
patch identity_email_url, params: { email: '[email protected]', current_password: 'SecretWrong1*3' } | ||
|
||
assert_redirected_to edit_identity_email_url | ||
assert_equal 'The password you entered is incorrect', flash[:alert] | ||
assert_redirected_to account_path | ||
assert_equal 'The password you entered is incorrect', flash[:emails_update_password_incorrect] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,27 +9,31 @@ class EmailsTest < ApplicationSystemTestCase | |
end | ||
|
||
test 'when I update my email address I should be prompted to verify it' do | ||
visit edit_identity_email_path | ||
visit account_path | ||
|
||
fill_in 'New email', with: '[email protected]' | ||
fill_in 'Current password', with: 'Secret1*3*5*' | ||
click_on 'Save changes' | ||
within(email_address_section) do | ||
fill_in 'New email', with: '[email protected]' | ||
fill_in 'Current password', with: 'Secret1*3*5*' | ||
click_on 'Save changes' | ||
end | ||
|
||
assert_text 'Your email has been changed' | ||
|
||
visit edit_identity_email_path | ||
visit account_path | ||
assert_text 'We sent a verification email to the address below' | ||
|
||
click_on 'Re-send verification email' | ||
assert_text 'We sent a verification email to your email address' | ||
end | ||
|
||
test 'updating my email address fails if my current password is wrong' do | ||
visit edit_identity_email_path | ||
visit account_path | ||
|
||
fill_in 'New email', with: '[email protected]' | ||
fill_in 'Current password', with: 'wrongpassword' | ||
click_on 'Save changes' | ||
within(email_address_section) do | ||
fill_in 'New email', with: '[email protected]' | ||
fill_in 'Current password', with: 'wrongpassword' | ||
click_on 'Save changes' | ||
end | ||
|
||
assert_text 'The password you entered is incorrect' | ||
refute_text 'We sent a verification email to the address below' | ||
|
@@ -38,14 +42,22 @@ class EmailsTest < ApplicationSystemTestCase | |
test 'updating my email address fails if I use an existing email' do | ||
existing_user = create(:user) | ||
|
||
visit edit_identity_email_path | ||
visit account_path | ||
|
||
fill_in 'New email', with: existing_user.email | ||
fill_in 'Current password', with: 'Secret1*3*5*' | ||
click_on 'Save changes' | ||
within(email_address_section) do | ||
fill_in 'New email', with: existing_user.email | ||
fill_in 'Current password', with: 'Secret1*3*5*' | ||
click_on 'Save changes' | ||
end | ||
|
||
assert_text 'Email has already been taken' | ||
refute_text 'We sent a verification email to the address below' | ||
end | ||
|
||
private | ||
|
||
def email_address_section | ||
find('h2', text: 'Email address').ancestor('section') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters