forked from heartcombo/devise
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request heartcombo#3570 from nviennot/no_more_bang
Removes the bang in confirm! and reset_password!
- Loading branch information
Showing
11 changed files
with
68 additions
and
54 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 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
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 |
---|---|---|
|
@@ -23,24 +23,24 @@ def setup | |
test 'should confirm a user by updating confirmed at' do | ||
user = create_user | ||
assert_nil user.confirmed_at | ||
assert user.confirm! | ||
assert user.confirm | ||
assert_not_nil user.confirmed_at | ||
end | ||
|
||
test 'should verify whether a user is confirmed or not' do | ||
assert_not new_user.confirmed? | ||
user = create_user | ||
assert_not user.confirmed? | ||
user.confirm! | ||
user.confirm | ||
assert user.confirmed? | ||
end | ||
|
||
test 'should not confirm a user already confirmed' do | ||
user = create_user | ||
assert user.confirm! | ||
assert user.confirm | ||
assert_blank user.errors[:email] | ||
|
||
assert_not user.confirm! | ||
assert_not user.confirm | ||
assert_equal "was already confirmed, please try signing in", user.errors[:email].join | ||
end | ||
|
||
|
@@ -169,7 +169,7 @@ def setup | |
test 'should not reset confirmation status or token when updating email' do | ||
user = create_user | ||
original_token = user.confirmation_token | ||
user.confirm! | ||
user.confirm | ||
user.email = '[email protected]' | ||
user.save! | ||
|
||
|
@@ -180,7 +180,7 @@ def setup | |
|
||
test 'should not be able to send instructions if the user is already confirmed' do | ||
user = create_user | ||
user.confirm! | ||
user.confirm | ||
assert_not user.resend_confirmation_instructions | ||
assert user.confirmed? | ||
assert_equal 'was already confirmed, please try signing in', user.errors[:email].join | ||
|
@@ -215,7 +215,7 @@ def setup | |
assert_not user.confirmed? | ||
assert_not user.active_for_authentication? | ||
|
||
user.confirm! | ||
user.confirm | ||
assert user.confirmed? | ||
assert user.active_for_authentication? | ||
end | ||
|
@@ -305,38 +305,38 @@ def confirm_user_by_token_with_confirmation_sent_at(confirmation_sent_at) | |
self.username = self.username.to_s + 'updated' | ||
end | ||
old = user.username | ||
assert user.confirm! | ||
assert user.confirm | ||
assert_not_equal user.username, old | ||
end | ||
|
||
test 'should not call after_confirmation if not confirmed' do | ||
user = create_user | ||
assert user.confirm! | ||
assert user.confirm | ||
user.define_singleton_method :after_confirmation do | ||
self.username = self.username.to_s + 'updated' | ||
end | ||
old = user.username | ||
assert_not user.confirm! | ||
assert_not user.confirm | ||
assert_equal user.username, old | ||
end | ||
|
||
test 'should always perform validations upon confirm when ensure valid true' do | ||
admin = create_admin | ||
admin.stubs(:valid?).returns(false) | ||
assert_not admin.confirm!(ensure_valid: true) | ||
assert_not admin.confirm(ensure_valid: true) | ||
end | ||
end | ||
|
||
class ReconfirmableTest < ActiveSupport::TestCase | ||
test 'should not worry about validations on confirm even with reconfirmable' do | ||
admin = create_admin | ||
admin.reset_password_token = "a" | ||
assert admin.confirm! | ||
assert admin.confirm | ||
end | ||
|
||
test 'should generate confirmation token after changing email' do | ||
admin = create_admin | ||
assert admin.confirm! | ||
assert admin.confirm | ||
residual_token = admin.confirmation_token | ||
assert admin.update_attributes(email: '[email protected]') | ||
assert_not_equal residual_token, admin.confirmation_token | ||
|
@@ -345,7 +345,7 @@ class ReconfirmableTest < ActiveSupport::TestCase | |
test 'should not regenerate confirmation token or require reconfirmation if skipping reconfirmation after changing email' do | ||
admin = create_admin | ||
original_token = admin.confirmation_token | ||
assert admin.confirm! | ||
assert admin.confirm | ||
admin.skip_reconfirmation! | ||
assert admin.update_attributes(email: '[email protected]') | ||
assert admin.confirmed? | ||
|
@@ -364,7 +364,7 @@ class ReconfirmableTest < ActiveSupport::TestCase | |
|
||
test 'should regenerate confirmation token after changing email' do | ||
admin = create_admin | ||
assert admin.confirm! | ||
assert admin.confirm | ||
assert admin.update_attributes(email: '[email protected]') | ||
token = admin.confirmation_token | ||
assert admin.update_attributes(email: '[email protected]') | ||
|
@@ -373,7 +373,7 @@ class ReconfirmableTest < ActiveSupport::TestCase | |
|
||
test 'should send confirmation instructions by email after changing email' do | ||
admin = create_admin | ||
assert admin.confirm! | ||
assert admin.confirm | ||
assert_email_sent "[email protected]" do | ||
assert admin.update_attributes(email: '[email protected]') | ||
end | ||
|
@@ -382,15 +382,15 @@ class ReconfirmableTest < ActiveSupport::TestCase | |
|
||
test 'should not send confirmation by email after changing password' do | ||
admin = create_admin | ||
assert admin.confirm! | ||
assert admin.confirm | ||
assert_email_not_sent do | ||
assert admin.update_attributes(password: 'newpass', password_confirmation: 'newpass') | ||
end | ||
end | ||
|
||
test 'should not send confirmation by email after changing to a blank email' do | ||
admin = create_admin | ||
assert admin.confirm! | ||
assert admin.confirm | ||
assert_email_not_sent do | ||
admin.email = '' | ||
admin.save(validate: false) | ||
|
@@ -399,23 +399,23 @@ class ReconfirmableTest < ActiveSupport::TestCase | |
|
||
test 'should stay confirmed when email is changed' do | ||
admin = create_admin | ||
assert admin.confirm! | ||
assert admin.confirm | ||
assert admin.update_attributes(email: '[email protected]') | ||
assert admin.confirmed? | ||
end | ||
|
||
test 'should update email only when it is confirmed' do | ||
admin = create_admin | ||
assert admin.confirm! | ||
assert admin.confirm | ||
assert admin.update_attributes(email: '[email protected]') | ||
assert_not_equal '[email protected]', admin.email | ||
assert admin.confirm! | ||
assert admin.confirm | ||
assert_equal '[email protected]', admin.email | ||
end | ||
|
||
test 'should not allow admin to get past confirmation email by resubmitting their new address' do | ||
admin = create_admin | ||
assert admin.confirm! | ||
assert admin.confirm | ||
assert admin.update_attributes(email: '[email protected]') | ||
assert_not_equal '[email protected]', admin.email | ||
assert admin.update_attributes(email: '[email protected]') | ||
|
@@ -424,7 +424,7 @@ class ReconfirmableTest < ActiveSupport::TestCase | |
|
||
test 'should find a admin by send confirmation instructions with unconfirmed_email' do | ||
admin = create_admin | ||
assert admin.confirm! | ||
assert admin.confirm | ||
assert admin.update_attributes(email: '[email protected]') | ||
confirmation_admin = Admin.send_confirmation_instructions(email: admin.unconfirmed_email) | ||
assert_equal confirmation_admin, admin | ||
|
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
Oops, something went wrong.