devise 3.2.3 → 3.2.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of devise might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +6 -6
- data/README.md +7 -0
- data/Rakefile +1 -1
- data/app/controllers/devise/confirmations_controller.rb +2 -2
- data/app/controllers/devise/omniauth_callbacks_controller.rb +2 -2
- data/app/controllers/devise/passwords_controller.rb +3 -3
- data/app/controllers/devise/registrations_controller.rb +7 -7
- data/app/controllers/devise/sessions_controller.rb +6 -6
- data/app/controllers/devise/unlocks_controller.rb +2 -2
- data/app/controllers/devise_controller.rb +3 -3
- data/app/helpers/devise_helper.rb +2 -2
- data/app/views/devise/confirmations/new.html.erb +2 -2
- data/app/views/devise/mailer/confirmation_instructions.html.erb +1 -1
- data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
- data/app/views/devise/mailer/unlock_instructions.html.erb +1 -1
- data/app/views/devise/passwords/edit.html.erb +3 -3
- data/app/views/devise/passwords/new.html.erb +2 -2
- data/app/views/devise/registrations/edit.html.erb +6 -6
- data/app/views/devise/registrations/new.html.erb +4 -4
- data/app/views/devise/sessions/new.html.erb +3 -3
- data/app/views/devise/unlocks/new.html.erb +2 -2
- data/devise.gemspec +1 -1
- data/gemfiles/Gemfile.rails-3.2-stable +3 -3
- data/gemfiles/Gemfile.rails-4.0-stable +3 -3
- data/gemfiles/Gemfile.rails-head +3 -3
- data/lib/devise.rb +3 -3
- data/lib/devise/controllers/helpers.rb +5 -5
- data/lib/devise/controllers/rememberable.rb +3 -3
- data/lib/devise/controllers/sign_in_out.rb +8 -8
- data/lib/devise/failure_app.rb +3 -3
- data/lib/devise/hooks/activatable.rb +1 -1
- data/lib/devise/hooks/lockable.rb +1 -1
- data/lib/devise/hooks/proxy.rb +1 -1
- data/lib/devise/hooks/rememberable.rb +1 -1
- data/lib/devise/hooks/timeoutable.rb +1 -1
- data/lib/devise/hooks/trackable.rb +1 -1
- data/lib/devise/mailers/helpers.rb +8 -8
- data/lib/devise/models/authenticatable.rb +3 -3
- data/lib/devise/models/confirmable.rb +9 -9
- data/lib/devise/models/database_authenticatable.rb +1 -1
- data/lib/devise/models/lockable.rb +6 -6
- data/lib/devise/models/omniauthable.rb +1 -1
- data/lib/devise/models/recoverable.rb +1 -1
- data/lib/devise/models/rememberable.rb +3 -3
- data/lib/devise/models/trackable.rb +1 -1
- data/lib/devise/models/validatable.rb +6 -6
- data/lib/devise/modules.rb +9 -9
- data/lib/devise/omniauth/url_helpers.rb +2 -2
- data/lib/devise/rails.rb +1 -1
- data/lib/devise/rails/routes.rb +81 -81
- data/lib/devise/test_helpers.rb +2 -2
- data/lib/devise/time_inflector.rb +1 -1
- data/lib/devise/version.rb +1 -1
- data/lib/generators/active_record/devise_generator.rb +6 -6
- data/lib/generators/active_record/templates/migration.rb +4 -4
- data/lib/generators/active_record/templates/migration_existing.rb +4 -4
- data/lib/generators/devise/devise_generator.rb +3 -3
- data/lib/generators/devise/views_generator.rb +29 -18
- data/lib/generators/mongoid/devise_generator.rb +19 -19
- data/lib/generators/templates/README +2 -2
- data/lib/generators/templates/devise.rb +9 -7
- data/lib/generators/templates/markerb/confirmation_instructions.markerb +1 -1
- data/lib/generators/templates/markerb/reset_password_instructions.markerb +1 -1
- data/lib/generators/templates/markerb/unlock_instructions.markerb +1 -1
- data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +2 -2
- data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +4 -4
- data/lib/generators/templates/simple_form_for/passwords/new.html.erb +2 -2
- data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +6 -6
- data/lib/generators/templates/simple_form_for/registrations/new.html.erb +4 -4
- data/lib/generators/templates/simple_form_for/sessions/new.html.erb +4 -4
- data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +2 -2
- data/test/controllers/helpers_test.rb +31 -31
- data/test/controllers/internal_helpers_test.rb +6 -6
- data/test/controllers/sessions_controller_test.rb +18 -18
- data/test/controllers/url_helpers_test.rb +4 -4
- data/test/delegator_test.rb +1 -1
- data/test/devise_test.rb +3 -3
- data/test/failure_app_test.rb +21 -21
- data/test/generators/active_record_generator_test.rb +4 -4
- data/test/generators/devise_generator_test.rb +2 -2
- data/test/generators/mongoid_generator_test.rb +1 -1
- data/test/generators/views_generator_test.rb +30 -1
- data/test/helpers/devise_helper_test.rb +11 -11
- data/test/integration/authenticatable_test.rb +42 -42
- data/test/integration/confirmable_test.rb +46 -46
- data/test/integration/database_authenticatable_test.rb +16 -16
- data/test/integration/http_authenticatable_test.rb +11 -11
- data/test/integration/lockable_test.rb +37 -37
- data/test/integration/omniauthable_test.rb +3 -3
- data/test/integration/recoverable_test.rb +41 -41
- data/test/integration/registerable_test.rb +49 -49
- data/test/integration/rememberable_test.rb +13 -13
- data/test/integration/timeoutable_test.rb +7 -7
- data/test/integration/trackable_test.rb +2 -2
- data/test/mailers/confirmation_instructions_test.rb +4 -4
- data/test/mailers/reset_password_instructions_test.rb +3 -3
- data/test/mailers/unlock_instructions_test.rb +2 -2
- data/test/models/authenticatable_test.rb +3 -3
- data/test/models/confirmable_test.rb +31 -31
- data/test/models/database_authenticatable_test.rb +27 -27
- data/test/models/lockable_test.rb +29 -29
- data/test/models/recoverable_test.rb +19 -19
- data/test/models/rememberable_test.rb +8 -8
- data/test/models/serializable_test.rb +8 -8
- data/test/models/timeoutable_test.rb +1 -1
- data/test/models/validatable_test.rb +11 -11
- data/test/omniauth/config_test.rb +3 -3
- data/test/omniauth/url_helpers_test.rb +3 -3
- data/test/parameter_sanitizer_test.rb +1 -1
- data/test/rails_app/app/controllers/admins_controller.rb +1 -1
- data/test/rails_app/app/controllers/application_controller.rb +2 -2
- data/test/rails_app/app/controllers/home_controller.rb +1 -1
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +2 -2
- data/test/rails_app/app/controllers/users_controller.rb +5 -5
- data/test/rails_app/app/mailers/users/mailer.rb +4 -4
- data/test/rails_app/app/mongoid/admin.rb +11 -11
- data/test/rails_app/app/mongoid/shim.rb +2 -2
- data/test/rails_app/app/mongoid/user.rb +19 -19
- data/test/rails_app/app/views/admins/sessions/new.html.erb +1 -1
- data/test/rails_app/app/views/layouts/application.html.erb +1 -1
- data/test/rails_app/config/application.rb +2 -2
- data/test/rails_app/config/initializers/devise.rb +3 -3
- data/test/rails_app/config/initializers/secret_token.rb +1 -1
- data/test/rails_app/config/routes.rb +43 -43
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +7 -7
- data/test/rails_app/lib/shared_admin.rb +4 -4
- data/test/routes_test.rb +59 -59
- data/test/support/helpers.rb +4 -4
- data/test/support/integration.rb +12 -12
- data/test/test_helpers_test.rb +3 -3
- data/test/test_models.rb +5 -5
- metadata +4 -4
@@ -31,7 +31,7 @@ class RememberMeTest < ActionDispatch::IntegrationTest
|
|
31
31
|
end
|
32
32
|
|
33
33
|
test 'handle unverified requests gets rid of caches' do
|
34
|
-
swap ApplicationController, :
|
34
|
+
swap ApplicationController, allow_forgery_protection: true do
|
35
35
|
post exhibit_user_url(1)
|
36
36
|
assert_not warden.authenticated?(:user)
|
37
37
|
|
@@ -43,19 +43,19 @@ class RememberMeTest < ActionDispatch::IntegrationTest
|
|
43
43
|
end
|
44
44
|
|
45
45
|
test 'handle unverified requests does not create cookies on sign in' do
|
46
|
-
swap ApplicationController, :
|
46
|
+
swap ApplicationController, allow_forgery_protection: true do
|
47
47
|
get new_user_session_path
|
48
48
|
assert request.session[:_csrf_token]
|
49
49
|
|
50
|
-
post user_session_path, :
|
51
|
-
{ email: "jose.valim@gmail.com", password: "123456", :
|
50
|
+
post user_session_path, authenticity_token: "oops", user:
|
51
|
+
{ email: "jose.valim@gmail.com", password: "123456", remember_me: "1" }
|
52
52
|
assert_not warden.authenticated?(:user)
|
53
53
|
assert_not request.cookies['remember_user_token']
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
test 'generate remember token after sign in' do
|
58
|
-
sign_in_as_user :
|
58
|
+
sign_in_as_user remember_me: true
|
59
59
|
assert request.cookies['remember_user_token']
|
60
60
|
end
|
61
61
|
|
@@ -63,15 +63,15 @@ class RememberMeTest < ActionDispatch::IntegrationTest
|
|
63
63
|
# We test this by asserting the cookie is not sent after the redirect
|
64
64
|
# since we changed the domain. This is the only difference with the
|
65
65
|
# previous test.
|
66
|
-
swap Devise, :
|
67
|
-
sign_in_as_user :
|
66
|
+
swap Devise, rememberable_options: { domain: "omg.somewhere.com" } do
|
67
|
+
sign_in_as_user remember_me: true
|
68
68
|
assert_nil request.cookies["remember_user_token"]
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
test 'generate remember token with a custom key' do
|
73
|
-
swap Devise, :
|
74
|
-
sign_in_as_user :
|
73
|
+
swap Devise, rememberable_options: { key: "v1lat_token" } do
|
74
|
+
sign_in_as_user remember_me: true
|
75
75
|
assert request.cookies["v1lat_token"]
|
76
76
|
end
|
77
77
|
end
|
@@ -79,7 +79,7 @@ class RememberMeTest < ActionDispatch::IntegrationTest
|
|
79
79
|
test 'generate remember token after sign in setting session options' do
|
80
80
|
begin
|
81
81
|
Rails.configuration.session_options[:domain] = "omg.somewhere.com"
|
82
|
-
sign_in_as_user :
|
82
|
+
sign_in_as_user remember_me: true
|
83
83
|
assert_nil request.cookies["remember_user_token"]
|
84
84
|
ensure
|
85
85
|
Rails.configuration.session_options.delete(:domain)
|
@@ -103,14 +103,14 @@ class RememberMeTest < ActionDispatch::IntegrationTest
|
|
103
103
|
end
|
104
104
|
|
105
105
|
test 'does not extend remember period through sign in' do
|
106
|
-
swap Devise, :
|
106
|
+
swap Devise, extend_remember_period: true, remember_for: 1.year do
|
107
107
|
user = create_user
|
108
108
|
user.remember_me!
|
109
109
|
|
110
110
|
user.remember_created_at = old = 10.days.ago
|
111
111
|
user.save
|
112
112
|
|
113
|
-
sign_in_as_user :
|
113
|
+
sign_in_as_user remember_me: true
|
114
114
|
user.reload
|
115
115
|
|
116
116
|
assert warden.user(:user) == user
|
@@ -135,7 +135,7 @@ class RememberMeTest < ActionDispatch::IntegrationTest
|
|
135
135
|
|
136
136
|
test 'do not remember with expired token' do
|
137
137
|
create_user_and_remember
|
138
|
-
swap Devise, :
|
138
|
+
swap Devise, remember_for: 0 do
|
139
139
|
get users_path
|
140
140
|
assert_not warden.authenticated?(:user)
|
141
141
|
assert_redirected_to new_user_session_path
|
@@ -104,7 +104,7 @@ class SessionTimeoutTest < ActionDispatch::IntegrationTest
|
|
104
104
|
user = sign_in_as_user
|
105
105
|
get expire_user_path(user)
|
106
106
|
|
107
|
-
post "/users/sign_in", :
|
107
|
+
post "/users/sign_in", email: user.email, password: "123456"
|
108
108
|
|
109
109
|
assert_response :redirect
|
110
110
|
follow_redirect!
|
@@ -129,7 +129,7 @@ class SessionTimeoutTest < ActionDispatch::IntegrationTest
|
|
129
129
|
end
|
130
130
|
|
131
131
|
test 'user configured timeout limit' do
|
132
|
-
swap Devise, :
|
132
|
+
swap Devise, timeout_in: 8.minutes do
|
133
133
|
user = sign_in_as_user
|
134
134
|
|
135
135
|
get users_path
|
@@ -145,8 +145,8 @@ class SessionTimeoutTest < ActionDispatch::IntegrationTest
|
|
145
145
|
end
|
146
146
|
|
147
147
|
test 'error message with i18n' do
|
148
|
-
store_translations :en, :
|
149
|
-
:
|
148
|
+
store_translations :en, devise: {
|
149
|
+
failure: { user: { timeout: 'Session expired!' } }
|
150
150
|
} do
|
151
151
|
user = sign_in_as_user
|
152
152
|
|
@@ -158,8 +158,8 @@ class SessionTimeoutTest < ActionDispatch::IntegrationTest
|
|
158
158
|
end
|
159
159
|
|
160
160
|
test 'error message with i18n with double redirect' do
|
161
|
-
store_translations :en, :
|
162
|
-
:
|
161
|
+
store_translations :en, devise: {
|
162
|
+
failure: { user: { timeout: 'Session expired!' } }
|
163
163
|
} do
|
164
164
|
user = sign_in_as_user
|
165
165
|
|
@@ -172,7 +172,7 @@ class SessionTimeoutTest < ActionDispatch::IntegrationTest
|
|
172
172
|
end
|
173
173
|
|
174
174
|
test 'time out not triggered if remembered' do
|
175
|
-
user = sign_in_as_user :
|
175
|
+
user = sign_in_as_user remember_me: true
|
176
176
|
get expire_user_path(user)
|
177
177
|
assert_not_nil last_request_at
|
178
178
|
|
@@ -63,8 +63,8 @@ class TrackableHooksTest < ActionDispatch::IntegrationTest
|
|
63
63
|
end
|
64
64
|
|
65
65
|
test "does not update anything if user has signed out along the way" do
|
66
|
-
swap Devise, :
|
67
|
-
user = create_user(:
|
66
|
+
swap Devise, allow_unconfirmed_access_for: 0.days do
|
67
|
+
user = create_user(confirm: false)
|
68
68
|
sign_in_as_user
|
69
69
|
|
70
70
|
user.reload
|
@@ -67,13 +67,13 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
|
|
67
67
|
end
|
68
68
|
|
69
69
|
test 'setup subject from I18n' do
|
70
|
-
store_translations :en, :
|
70
|
+
store_translations :en, devise: { mailer: { confirmation_instructions: { subject: 'Account Confirmation' } } } do
|
71
71
|
assert_equal 'Account Confirmation', mail.subject
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
75
|
test 'subject namespaced by model' do
|
76
|
-
store_translations :en, :
|
76
|
+
store_translations :en, devise: { mailer: { confirmation_instructions: { user_subject: 'User Account Confirmation' } } } do
|
77
77
|
assert_equal 'User Account Confirmation', mail.subject
|
78
78
|
end
|
79
79
|
end
|
@@ -93,7 +93,7 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
|
|
93
93
|
end
|
94
94
|
|
95
95
|
test 'renders a scoped if scoped_views is set to true' do
|
96
|
-
swap Devise, :
|
96
|
+
swap Devise, scoped_views: true do
|
97
97
|
assert_equal user.email, mail.body.decoded
|
98
98
|
end
|
99
99
|
end
|
@@ -108,7 +108,7 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
|
|
108
108
|
end
|
109
109
|
|
110
110
|
test 'mailer sender accepts a proc' do
|
111
|
-
swap Devise, :
|
111
|
+
swap Devise, mailer_sender: proc { "another@example.com" } do
|
112
112
|
assert_equal ['another@example.com'], mail.from
|
113
113
|
end
|
114
114
|
end
|
@@ -63,13 +63,13 @@ class ResetPasswordInstructionsTest < ActionMailer::TestCase
|
|
63
63
|
end
|
64
64
|
|
65
65
|
test 'setup subject from I18n' do
|
66
|
-
store_translations :en, :
|
66
|
+
store_translations :en, devise: { mailer: { reset_password_instructions: { subject: 'Reset instructions' } } } do
|
67
67
|
assert_equal 'Reset instructions', mail.subject
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
71
|
test 'subject namespaced by model' do
|
72
|
-
store_translations :en, :
|
72
|
+
store_translations :en, devise: { mailer: { reset_password_instructions: { user_subject: 'User Reset Instructions' } } } do
|
73
73
|
assert_equal 'User Reset Instructions', mail.subject
|
74
74
|
end
|
75
75
|
end
|
@@ -89,7 +89,7 @@ class ResetPasswordInstructionsTest < ActionMailer::TestCase
|
|
89
89
|
end
|
90
90
|
|
91
91
|
test 'mailer sender accepts a proc' do
|
92
|
-
swap Devise, :
|
92
|
+
swap Devise, mailer_sender: proc { "another@example.com" } do
|
93
93
|
assert_equal ['another@example.com'], mail.from
|
94
94
|
end
|
95
95
|
end
|
@@ -64,13 +64,13 @@ class UnlockInstructionsTest < ActionMailer::TestCase
|
|
64
64
|
end
|
65
65
|
|
66
66
|
test 'setup subject from I18n' do
|
67
|
-
store_translations :en, :
|
67
|
+
store_translations :en, devise: { mailer: { unlock_instructions: { subject: 'Yo unlock instructions' } } } do
|
68
68
|
assert_equal 'Yo unlock instructions', mail.subject
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
test 'subject namespaced by model' do
|
73
|
-
store_translations :en, :
|
73
|
+
store_translations :en, devise: { mailer: { unlock_instructions: { user_subject: 'User Unlock Instructions' } } } do
|
74
74
|
assert_equal 'User Unlock Instructions', mail.subject
|
75
75
|
end
|
76
76
|
end
|
@@ -6,8 +6,8 @@ class AuthenticatableTest < ActiveSupport::TestCase
|
|
6
6
|
end
|
7
7
|
|
8
8
|
test 'find_first_by_auth_conditions allows custom filtering parameters' do
|
9
|
-
user = User.create!(:
|
10
|
-
assert_equal User.find_first_by_auth_conditions({ :
|
11
|
-
assert_nil User.find_first_by_auth_conditions({ :
|
9
|
+
user = User.create!(email: "example@example.com", password: "123456")
|
10
|
+
assert_equal User.find_first_by_auth_conditions({ email: "example@example.com" }), user
|
11
|
+
assert_nil User.find_first_by_auth_conditions({ email: "example@example.com" }, id: user.id.to_s.next)
|
12
12
|
end
|
13
13
|
end
|
@@ -82,7 +82,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
|
82
82
|
|
83
83
|
test 'should send confirmation instructions by email' do
|
84
84
|
assert_email_sent "mynewuser@example.com" do
|
85
|
-
create_user :
|
85
|
+
create_user email: "mynewuser@example.com"
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -119,23 +119,23 @@ class ConfirmableTest < ActiveSupport::TestCase
|
|
119
119
|
assert_email_not_sent do
|
120
120
|
user = new_user
|
121
121
|
user.email = ''
|
122
|
-
user.save(:
|
122
|
+
user.save(validate: false)
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
126
|
test 'should find a user to send confirmation instructions' do
|
127
127
|
user = create_user
|
128
|
-
confirmation_user = User.send_confirmation_instructions(:
|
128
|
+
confirmation_user = User.send_confirmation_instructions(email: user.email)
|
129
129
|
assert_equal confirmation_user, user
|
130
130
|
end
|
131
131
|
|
132
132
|
test 'should return a new user if no email was found' do
|
133
|
-
confirmation_user = User.send_confirmation_instructions(:
|
133
|
+
confirmation_user = User.send_confirmation_instructions(email: "invalid@example.com")
|
134
134
|
assert_not confirmation_user.persisted?
|
135
135
|
end
|
136
136
|
|
137
137
|
test 'should add error to new user email if no email was found' do
|
138
|
-
confirmation_user = User.send_confirmation_instructions(:
|
138
|
+
confirmation_user = User.send_confirmation_instructions(email: "invalid@example.com")
|
139
139
|
assert confirmation_user.errors[:email]
|
140
140
|
assert_equal "not found", confirmation_user.errors[:email].join
|
141
141
|
end
|
@@ -143,7 +143,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
|
143
143
|
test 'should send email instructions for the user confirm its email' do
|
144
144
|
user = create_user
|
145
145
|
assert_email_sent user.email do
|
146
|
-
User.send_confirmation_instructions(:
|
146
|
+
User.send_confirmation_instructions(email: user.email)
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
@@ -183,7 +183,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
|
183
183
|
end
|
184
184
|
|
185
185
|
test 'confirm time should fallback to devise confirm in default configuration' do
|
186
|
-
swap Devise, :
|
186
|
+
swap Devise, allow_unconfirmed_access_for: 1.day do
|
187
187
|
user = new_user
|
188
188
|
user.confirmation_sent_at = 2.days.ago
|
189
189
|
assert_not user.active_for_authentication?
|
@@ -194,7 +194,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
|
194
194
|
end
|
195
195
|
|
196
196
|
test 'should be active when confirmation sent at is not overpast' do
|
197
|
-
swap Devise, :
|
197
|
+
swap Devise, allow_unconfirmed_access_for: 5.days do
|
198
198
|
Devise.allow_unconfirmed_access_for = 5.days
|
199
199
|
user = create_user
|
200
200
|
|
@@ -246,17 +246,17 @@ class ConfirmableTest < ActiveSupport::TestCase
|
|
246
246
|
end
|
247
247
|
|
248
248
|
test 'should find a user to send email instructions for the user confirm its email by authentication_keys' do
|
249
|
-
swap Devise, :
|
249
|
+
swap Devise, authentication_keys: [:username, :email] do
|
250
250
|
user = create_user
|
251
|
-
confirm_user = User.send_confirmation_instructions(:
|
251
|
+
confirm_user = User.send_confirmation_instructions(email: user.email, username: user.username)
|
252
252
|
assert_equal confirm_user, user
|
253
253
|
end
|
254
254
|
end
|
255
255
|
|
256
256
|
test 'should require all confirmation_keys' do
|
257
|
-
swap Devise, :
|
257
|
+
swap Devise, confirmation_keys: [:username, :email] do
|
258
258
|
user = create_user
|
259
|
-
confirm_user = User.send_confirmation_instructions(:
|
259
|
+
confirm_user = User.send_confirmation_instructions(email: user.email)
|
260
260
|
assert_not confirm_user.persisted?
|
261
261
|
assert_equal "can't be blank", confirm_user.errors[:username].join
|
262
262
|
end
|
@@ -275,13 +275,13 @@ class ConfirmableTest < ActiveSupport::TestCase
|
|
275
275
|
end
|
276
276
|
|
277
277
|
test 'should accept confirmation email token after 2 days when expiration is set to 3 days' do
|
278
|
-
swap Devise, :
|
278
|
+
swap Devise, confirm_within: 3.days do
|
279
279
|
assert confirm_user_by_token_with_confirmation_sent_at(2.days.ago)
|
280
280
|
end
|
281
281
|
end
|
282
282
|
|
283
283
|
test 'should not accept confirmation email token after 4 days when expiration is set to 3 days' do
|
284
|
-
swap Devise, :
|
284
|
+
swap Devise, confirm_within: 3.days do
|
285
285
|
assert_not confirm_user_by_token_with_confirmation_sent_at(4.days.ago)
|
286
286
|
end
|
287
287
|
end
|
@@ -327,7 +327,7 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
|
327
327
|
admin = create_admin
|
328
328
|
assert admin.confirm!
|
329
329
|
assert_nil admin.confirmation_token
|
330
|
-
assert admin.update_attributes(:
|
330
|
+
assert admin.update_attributes(email: 'new_test@example.com')
|
331
331
|
assert_not_nil admin.confirmation_token
|
332
332
|
end
|
333
333
|
|
@@ -335,7 +335,7 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
|
335
335
|
admin = create_admin
|
336
336
|
assert admin.confirm!
|
337
337
|
admin.skip_reconfirmation!
|
338
|
-
assert admin.update_attributes(:
|
338
|
+
assert admin.update_attributes(email: 'new_test@example.com')
|
339
339
|
assert_nil admin.confirmation_token
|
340
340
|
end
|
341
341
|
|
@@ -344,16 +344,16 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
|
344
344
|
admin.skip_confirmation_notification!
|
345
345
|
|
346
346
|
assert_email_not_sent do
|
347
|
-
admin.update_attributes(:
|
347
|
+
admin.update_attributes(email: 'new_test@example.com')
|
348
348
|
end
|
349
349
|
end
|
350
350
|
|
351
351
|
test 'should regenerate confirmation token after changing email' do
|
352
352
|
admin = create_admin
|
353
353
|
assert admin.confirm!
|
354
|
-
assert admin.update_attributes(:
|
354
|
+
assert admin.update_attributes(email: 'old_test@example.com')
|
355
355
|
token = admin.confirmation_token
|
356
|
-
assert admin.update_attributes(:
|
356
|
+
assert admin.update_attributes(email: 'new_test@example.com')
|
357
357
|
assert_not_equal token, admin.confirmation_token
|
358
358
|
end
|
359
359
|
|
@@ -361,7 +361,7 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
|
361
361
|
admin = create_admin
|
362
362
|
assert admin.confirm!
|
363
363
|
assert_email_sent "new_test@example.com" do
|
364
|
-
assert admin.update_attributes(:
|
364
|
+
assert admin.update_attributes(email: 'new_test@example.com')
|
365
365
|
end
|
366
366
|
assert_match "new_test@example.com", ActionMailer::Base.deliveries.last.body.encoded
|
367
367
|
end
|
@@ -370,7 +370,7 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
|
370
370
|
admin = create_admin
|
371
371
|
assert admin.confirm!
|
372
372
|
assert_email_not_sent do
|
373
|
-
assert admin.update_attributes(:
|
373
|
+
assert admin.update_attributes(password: 'newpass', password_confirmation: 'newpass')
|
374
374
|
end
|
375
375
|
end
|
376
376
|
|
@@ -379,21 +379,21 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
|
379
379
|
assert admin.confirm!
|
380
380
|
assert_email_not_sent do
|
381
381
|
admin.email = ''
|
382
|
-
admin.save(:
|
382
|
+
admin.save(validate: false)
|
383
383
|
end
|
384
384
|
end
|
385
385
|
|
386
386
|
test 'should stay confirmed when email is changed' do
|
387
387
|
admin = create_admin
|
388
388
|
assert admin.confirm!
|
389
|
-
assert admin.update_attributes(:
|
389
|
+
assert admin.update_attributes(email: 'new_test@example.com')
|
390
390
|
assert admin.confirmed?
|
391
391
|
end
|
392
392
|
|
393
393
|
test 'should update email only when it is confirmed' do
|
394
394
|
admin = create_admin
|
395
395
|
assert admin.confirm!
|
396
|
-
assert admin.update_attributes(:
|
396
|
+
assert admin.update_attributes(email: 'new_test@example.com')
|
397
397
|
assert_not_equal 'new_test@example.com', admin.email
|
398
398
|
assert admin.confirm!
|
399
399
|
assert_equal 'new_test@example.com', admin.email
|
@@ -402,27 +402,27 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
|
402
402
|
test 'should not allow admin to get past confirmation email by resubmitting their new address' do
|
403
403
|
admin = create_admin
|
404
404
|
assert admin.confirm!
|
405
|
-
assert admin.update_attributes(:
|
405
|
+
assert admin.update_attributes(email: 'new_test@example.com')
|
406
406
|
assert_not_equal 'new_test@example.com', admin.email
|
407
|
-
assert admin.update_attributes(:
|
407
|
+
assert admin.update_attributes(email: 'new_test@example.com')
|
408
408
|
assert_not_equal 'new_test@example.com', admin.email
|
409
409
|
end
|
410
410
|
|
411
411
|
test 'should find a admin by send confirmation instructions with unconfirmed_email' do
|
412
412
|
admin = create_admin
|
413
413
|
assert admin.confirm!
|
414
|
-
assert admin.update_attributes(:
|
415
|
-
confirmation_admin = Admin.send_confirmation_instructions(:
|
414
|
+
assert admin.update_attributes(email: 'new_test@example.com')
|
415
|
+
confirmation_admin = Admin.send_confirmation_instructions(email: admin.unconfirmed_email)
|
416
416
|
assert_equal confirmation_admin, admin
|
417
417
|
end
|
418
418
|
|
419
419
|
test 'should return a new admin if no email or unconfirmed_email was found' do
|
420
|
-
confirmation_admin = Admin.send_confirmation_instructions(:
|
420
|
+
confirmation_admin = Admin.send_confirmation_instructions(email: "invalid@email.com")
|
421
421
|
assert_not confirmation_admin.persisted?
|
422
422
|
end
|
423
423
|
|
424
424
|
test 'should add error to new admin email if no email or unconfirmed_email was found' do
|
425
|
-
confirmation_admin = Admin.send_confirmation_instructions(:
|
425
|
+
confirmation_admin = Admin.send_confirmation_instructions(email: "invalid@email.com")
|
426
426
|
assert confirmation_admin.errors[:email]
|
427
427
|
assert_equal "not found", confirmation_admin.errors[:email].join
|
428
428
|
end
|
@@ -431,7 +431,7 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
|
431
431
|
admin = create_admin
|
432
432
|
admin.unconfirmed_email = "new_test@email.com"
|
433
433
|
assert admin.save
|
434
|
-
admin = Admin.find_by_unconfirmed_email_with_errors(:
|
434
|
+
admin = Admin.find_by_unconfirmed_email_with_errors(email: "new_test@email.com")
|
435
435
|
assert admin.persisted?
|
436
436
|
end
|
437
437
|
|