-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable sign_in_after_change_password option only when changing password
- Loading branch information
Showing
2 changed files
with
25 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,7 +179,7 @@ def user_sign_up | |
assert warden.authenticated?(:user) | ||
end | ||
|
||
test 'a signed in user should not still be able to use the website after changing their password if config.sign_in_after_change_password is false' do | ||
test 'a signed in user should not be able to use the website after changing their password if config.sign_in_after_change_password is false' do | ||
swap Devise, sign_in_after_change_password: false do | ||
sign_in_as_user | ||
get edit_user_registration_path | ||
|
@@ -191,7 +191,24 @@ def user_sign_up | |
|
||
assert_contain 'Your account has been updated successfully, but since your password was changed, you need to sign in again' | ||
assert_equal new_user_session_path, @request.path | ||
assert !warden.authenticated?(:user) | ||
refute warden.authenticated?(:user) | ||
end | ||
end | ||
|
||
test 'a signed in user should be able to use the website after changing its email with config.sign_in_after_change_password is false' do | ||
swap Devise, sign_in_after_change_password: false do | ||
sign_in_as_user | ||
get edit_user_registration_path | ||
|
||
fill_in 'email', with: '[email protected]' | ||
fill_in 'current password', with: '12345678' | ||
click_button 'Update' | ||
|
||
assert_current_url '/' | ||
assert_contain 'Your account has been updated successfully.' | ||
|
||
assert warden.authenticated?(:user) | ||
assert_equal "[email protected]", User.to_adapter.find_first.email | ||
end | ||
end | ||
|
||
|