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 remote-tracking branch 'heimidal/updates' into reconfirm
Conflicts: lib/devise/models/confirmable.rb test/support/helpers.rb
- Loading branch information
Showing
15 changed files
with
346 additions
and
17 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<p>Welcome <%= @resource.email %>!</p> | ||
|
||
<p>You can confirm your account through the link below:</p> | ||
<p>You can confirm your account email through the link below:</p> | ||
|
||
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p> |
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 |
---|---|---|
|
@@ -201,3 +201,64 @@ def resend_confirmation | |
end | ||
end | ||
end | ||
|
||
class ConfirmationOnChangeTest < ConfirmationTest | ||
|
||
def create_second_user(options={}) | ||
@user = nil | ||
create_user(options) | ||
end | ||
|
||
def setup | ||
add_unconfirmed_email_column | ||
Devise.reconfirmable = true | ||
end | ||
|
||
def teardown | ||
remove_unconfirmed_email_column | ||
Devise.reconfirmable = false | ||
end | ||
|
||
test 'user should be able to request a new confirmation after email changed' do | ||
user = create_user(:confirm => true) | ||
user.update_attributes(:email => '[email protected]') | ||
ActionMailer::Base.deliveries.clear | ||
|
||
visit new_user_session_path | ||
click_link "Didn't receive confirmation instructions?" | ||
|
||
fill_in 'email', :with => user.unconfirmed_email | ||
click_button 'Resend confirmation instructions' | ||
|
||
assert_current_url '/users/sign_in' | ||
assert_contain 'You will receive an email with instructions about how to confirm your account in a few minutes' | ||
assert_equal 1, ActionMailer::Base.deliveries.size | ||
end | ||
|
||
test 'user with valid confirmation token should be able to confirm email after email changed' do | ||
user = create_user(:confirm => true) | ||
user.update_attributes(:email => '[email protected]') | ||
assert '[email protected]', user.unconfirmed_email | ||
visit_user_confirmation_with_token(user.confirmation_token) | ||
|
||
assert_contain 'Your account was successfully confirmed.' | ||
assert_current_url '/' | ||
assert user.reload.confirmed? | ||
end | ||
|
||
test 'user email should be unique also within unconfirmed_email' do | ||
user = create_user(:confirm => true) | ||
user.update_attributes(:email => '[email protected]') | ||
assert '[email protected]', user.unconfirmed_email | ||
|
||
get new_user_registration_path | ||
|
||
fill_in 'email', :with => '[email protected]' | ||
fill_in 'password', :with => 'new_user123' | ||
fill_in 'password confirmation', :with => 'new_user123' | ||
click_button 'Sign up' | ||
|
||
assert_have_selector '#error_explanation' | ||
assert_contain /Email.*already.*taken/ | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -291,3 +291,45 @@ def user_sign_up | |
assert_equal User.count, 0 | ||
end | ||
end | ||
|
||
class ReconfirmableRegistrationTest < ActionController::IntegrationTest | ||
def setup | ||
add_unconfirmed_email_column | ||
Devise.reconfirmable = true | ||
end | ||
|
||
def teardown | ||
remove_unconfirmed_email_column | ||
Devise.reconfirmable = false | ||
end | ||
|
||
test 'a signed in user should see a more appropriate flash message when editing his account if reconfirmable is enabled' do | ||
sign_in_as_user | ||
get edit_user_registration_path | ||
|
||
fill_in 'email', :with => '[email protected]' | ||
fill_in 'current password', :with => '123456' | ||
click_button 'Update' | ||
|
||
assert_current_url '/' | ||
assert_contain 'You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize your new email address.' | ||
|
||
assert_equal "[email protected]", User.first.unconfirmed_email | ||
end | ||
|
||
test 'A signed in user should not see a reconfirmation message if they did not change their password' do | ||
sign_in_as_user | ||
get edit_user_registration_path | ||
|
||
fill_in 'password', :with => 'pas123' | ||
fill_in 'password confirmation', :with => 'pas123' | ||
fill_in 'current password', :with => '123456' | ||
click_button 'Update' | ||
|
||
assert_current_url '/' | ||
assert_contain 'You updated your account successfully.' | ||
|
||
assert User.first.valid_password?('pas123') | ||
end | ||
end | ||
|
Oops, something went wrong.