devise 4.1.1 → 4.2.0
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/.travis.yml +9 -7
- data/CHANGELOG.md +46 -2
- data/CONTRIBUTING.md +30 -7
- data/Gemfile +14 -7
- data/Gemfile.lock +96 -81
- data/README.md +89 -37
- data/app/controllers/devise/omniauth_callbacks_controller.rb +3 -3
- data/app/controllers/devise/registrations_controller.rb +3 -3
- data/app/views/devise/registrations/edit.html.erb +4 -0
- data/gemfiles/Gemfile.rails-4.1-stable +4 -4
- data/gemfiles/Gemfile.rails-4.1-stable.lock +27 -23
- data/gemfiles/Gemfile.rails-4.2-stable +4 -4
- data/gemfiles/Gemfile.rails-4.2-stable.lock +58 -54
- data/guides/bug_report_templates/integration_test.rb +104 -0
- data/lib/devise.rb +21 -14
- data/lib/devise/controllers/helpers.rb +12 -1
- data/lib/devise/controllers/rememberable.rb +1 -1
- data/lib/devise/controllers/sign_in_out.rb +25 -10
- data/lib/devise/failure_app.rb +25 -17
- data/lib/devise/hooks/proxy.rb +1 -1
- data/lib/devise/models/authenticatable.rb +23 -2
- data/lib/devise/models/confirmable.rb +13 -7
- data/lib/devise/models/database_authenticatable.rb +0 -5
- data/lib/devise/models/recoverable.rb +10 -15
- data/lib/devise/omniauth/url_helpers.rb +0 -51
- data/lib/devise/orm/active_record.rb +3 -1
- data/lib/devise/orm/mongoid.rb +4 -2
- data/lib/devise/parameter_sanitizer.rb +0 -55
- data/lib/devise/rails.rb +3 -1
- data/lib/devise/test/controller_helpers.rb +162 -0
- data/lib/devise/test/integration_helpers.rb +61 -0
- data/lib/devise/test_helpers.rb +5 -129
- data/lib/devise/version.rb +1 -1
- data/lib/generators/templates/README +1 -8
- data/lib/generators/templates/devise.rb +6 -0
- data/test/controllers/custom_registrations_controller_test.rb +1 -1
- data/test/controllers/custom_strategy_test.rb +1 -1
- data/test/controllers/helpers_test.rb +4 -4
- data/test/controllers/internal_helpers_test.rb +1 -1
- data/test/controllers/passwords_controller_test.rb +1 -1
- data/test/controllers/sessions_controller_test.rb +2 -2
- data/test/devise_test.rb +9 -9
- data/test/failure_app_test.rb +18 -0
- data/test/integration/authenticatable_test.rb +36 -36
- data/test/integration/confirmable_test.rb +7 -7
- data/test/integration/database_authenticatable_test.rb +5 -5
- data/test/integration/http_authenticatable_test.rb +2 -2
- data/test/integration/lockable_test.rb +1 -1
- data/test/integration/mounted_engine_test.rb +36 -0
- data/test/integration/omniauthable_test.rb +1 -1
- data/test/integration/recoverable_test.rb +4 -4
- data/test/integration/registerable_test.rb +12 -6
- data/test/integration/rememberable_test.rb +10 -10
- data/test/integration/timeoutable_test.rb +5 -5
- data/test/mapping_test.rb +1 -1
- data/test/models/confirmable_test.rb +33 -25
- data/test/models/database_authenticatable_test.rb +13 -13
- data/test/models/lockable_test.rb +16 -16
- data/test/models/omniauthable_test.rb +1 -1
- data/test/models/recoverable_test.rb +10 -10
- data/test/models/registerable_test.rb +1 -1
- data/test/models/rememberable_test.rb +16 -3
- data/test/models/serializable_test.rb +5 -0
- data/test/models/timeoutable_test.rb +7 -7
- data/test/models/trackable_test.rb +1 -1
- data/test/models/validatable_test.rb +1 -1
- data/test/models_test.rb +2 -2
- data/test/parameter_sanitizer_test.rb +0 -56
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +1 -1
- data/test/rails_app/config/environments/production.rb +3 -1
- data/test/rails_app/config/environments/test.rb +5 -6
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +5 -1
- data/test/support/assertions.rb +0 -11
- data/test/{test_helpers_test.rb → test/controller_helpers_test.rb} +2 -2
- data/test/test/integration_helpers_test.rb +32 -0
- metadata +11 -6
- data/gemfiles/Gemfile.rails-5.0-beta +0 -37
- data/gemfiles/Gemfile.rails-5.0-beta.lock +0 -199
@@ -124,7 +124,7 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
|
124
124
|
test 'should test for a valid password' do
|
125
125
|
user = create_user
|
126
126
|
assert user.valid_password?('12345678')
|
127
|
-
|
127
|
+
refute user.valid_password?('654321')
|
128
128
|
end
|
129
129
|
|
130
130
|
test 'should not raise error with an empty password' do
|
@@ -136,7 +136,7 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
|
136
136
|
test 'should be an invalid password if the user has an empty password' do
|
137
137
|
user = create_user
|
138
138
|
user.encrypted_password = ''
|
139
|
-
|
139
|
+
refute user.valid_password?('654321')
|
140
140
|
end
|
141
141
|
|
142
142
|
test 'should respond to current password' do
|
@@ -152,7 +152,7 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
|
152
152
|
|
153
153
|
test 'should add an error to current password when it is invalid' do
|
154
154
|
user = create_user
|
155
|
-
|
155
|
+
refute user.update_with_password(current_password: 'other',
|
156
156
|
password: 'pass4321', password_confirmation: 'pass4321')
|
157
157
|
assert user.reload.valid_password?('12345678')
|
158
158
|
assert_match "is invalid", user.errors[:current_password].join
|
@@ -160,7 +160,7 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
|
160
160
|
|
161
161
|
test 'should add an error to current password when it is blank' do
|
162
162
|
user = create_user
|
163
|
-
|
163
|
+
refute user.update_with_password(password: 'pass4321',
|
164
164
|
password_confirmation: 'pass4321')
|
165
165
|
assert user.reload.valid_password?('12345678')
|
166
166
|
assert_match "can't be blank", user.errors[:current_password].join
|
@@ -170,7 +170,7 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
|
170
170
|
user = UserWithValidation.create!(valid_attributes)
|
171
171
|
user.save
|
172
172
|
assert user.persisted?
|
173
|
-
|
173
|
+
refute user.update_with_password(username: "")
|
174
174
|
assert_match "usertest", user.reload.username
|
175
175
|
assert_match "can't be blank", user.errors[:username].join
|
176
176
|
end
|
@@ -183,14 +183,14 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
|
183
183
|
|
184
184
|
test 'should not update password with invalid confirmation' do
|
185
185
|
user = create_user
|
186
|
-
|
186
|
+
refute user.update_with_password(current_password: '12345678',
|
187
187
|
password: 'pass4321', password_confirmation: 'other')
|
188
188
|
assert user.reload.valid_password?('12345678')
|
189
189
|
end
|
190
190
|
|
191
191
|
test 'should clean up password fields on failure' do
|
192
192
|
user = create_user
|
193
|
-
|
193
|
+
refute user.update_with_password(current_password: '12345678',
|
194
194
|
password: 'pass4321', password_confirmation: 'other')
|
195
195
|
assert user.password.blank?
|
196
196
|
assert user.password_confirmation.blank?
|
@@ -217,14 +217,14 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
|
217
217
|
|
218
218
|
test 'should not destroy user with invalid password' do
|
219
219
|
user = create_user
|
220
|
-
|
220
|
+
refute user.destroy_with_password('other')
|
221
221
|
assert user.persisted?
|
222
222
|
assert_match "is invalid", user.errors[:current_password].join
|
223
223
|
end
|
224
224
|
|
225
225
|
test 'should not destroy user with blank password' do
|
226
226
|
user = create_user
|
227
|
-
|
227
|
+
refute user.destroy_with_password(nil)
|
228
228
|
assert user.persisted?
|
229
229
|
assert_match "can't be blank", user.errors[:current_password].join
|
230
230
|
end
|
@@ -252,15 +252,15 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
|
252
252
|
end
|
253
253
|
|
254
254
|
test 'required_fields should be encryptable_password and the email field by default' do
|
255
|
-
|
256
|
-
:
|
257
|
-
:
|
255
|
+
assert_equal Devise::Models::DatabaseAuthenticatable.required_fields(User), [
|
256
|
+
:encrypted_password,
|
257
|
+
:email
|
258
258
|
]
|
259
259
|
end
|
260
260
|
|
261
261
|
test 'required_fields should be encryptable_password and the login when the login is on authentication_keys' do
|
262
262
|
swap Devise, authentication_keys: [:login] do
|
263
|
-
|
263
|
+
assert_equal Devise::Models::DatabaseAuthenticatable.required_fields(User), [
|
264
264
|
:encrypted_password,
|
265
265
|
:login
|
266
266
|
]
|
@@ -46,7 +46,7 @@ class LockableTest < ActiveSupport::TestCase
|
|
46
46
|
|
47
47
|
test "should verify whether a user is locked or not" do
|
48
48
|
user = create_user
|
49
|
-
|
49
|
+
refute user.access_locked?
|
50
50
|
user.lock_access!
|
51
51
|
assert user.access_locked?
|
52
52
|
end
|
@@ -56,7 +56,7 @@ class LockableTest < ActiveSupport::TestCase
|
|
56
56
|
user.confirm
|
57
57
|
assert user.active_for_authentication?
|
58
58
|
user.lock_access!
|
59
|
-
|
59
|
+
refute user.active_for_authentication?
|
60
60
|
end
|
61
61
|
|
62
62
|
test "should unlock a user by cleaning locked_at, failed_attempts and unlock_token" do
|
@@ -72,7 +72,7 @@ class LockableTest < ActiveSupport::TestCase
|
|
72
72
|
end
|
73
73
|
|
74
74
|
test "new user should not be locked and should have zero failed_attempts" do
|
75
|
-
|
75
|
+
refute new_user.access_locked?
|
76
76
|
assert_equal 0, create_user.failed_attempts
|
77
77
|
end
|
78
78
|
|
@@ -83,7 +83,7 @@ class LockableTest < ActiveSupport::TestCase
|
|
83
83
|
assert user.access_locked?
|
84
84
|
|
85
85
|
Devise.unlock_in = 1.hour
|
86
|
-
|
86
|
+
refute user.access_locked?
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -162,18 +162,18 @@ class LockableTest < ActiveSupport::TestCase
|
|
162
162
|
raw = user.send_unlock_instructions
|
163
163
|
locked_user = User.unlock_access_by_token(raw)
|
164
164
|
assert_equal locked_user, user
|
165
|
-
|
165
|
+
refute user.reload.access_locked?
|
166
166
|
end
|
167
167
|
|
168
168
|
test 'should return a new record with errors when a invalid token is given' do
|
169
169
|
locked_user = User.unlock_access_by_token('invalid_token')
|
170
|
-
|
170
|
+
refute locked_user.persisted?
|
171
171
|
assert_equal "is invalid", locked_user.errors[:unlock_token].join
|
172
172
|
end
|
173
173
|
|
174
174
|
test 'should return a new record with errors when a blank token is given' do
|
175
175
|
locked_user = User.unlock_access_by_token('')
|
176
|
-
|
176
|
+
refute locked_user.persisted?
|
177
177
|
assert_equal "can't be blank", locked_user.errors[:unlock_token].join
|
178
178
|
end
|
179
179
|
|
@@ -186,7 +186,7 @@ class LockableTest < ActiveSupport::TestCase
|
|
186
186
|
|
187
187
|
test 'should return a new user if no email was found' do
|
188
188
|
unlock_user = User.send_unlock_instructions(email: "invalid@example.com")
|
189
|
-
|
189
|
+
refute unlock_user.persisted?
|
190
190
|
end
|
191
191
|
|
192
192
|
test 'should add error to new user email if no email was found' do
|
@@ -206,23 +206,23 @@ class LockableTest < ActiveSupport::TestCase
|
|
206
206
|
swap Devise, unlock_keys: [:username, :email] do
|
207
207
|
user = create_user
|
208
208
|
unlock_user = User.send_unlock_instructions(email: user.email)
|
209
|
-
|
209
|
+
refute unlock_user.persisted?
|
210
210
|
assert_equal "can't be blank", unlock_user.errors[:username].join
|
211
211
|
end
|
212
212
|
end
|
213
213
|
|
214
214
|
test 'should not be able to send instructions if the user is not locked' do
|
215
215
|
user = create_user
|
216
|
-
|
217
|
-
|
216
|
+
refute user.resend_unlock_instructions
|
217
|
+
refute user.access_locked?
|
218
218
|
assert_equal 'was not locked', user.errors[:email].join
|
219
219
|
end
|
220
220
|
|
221
221
|
test 'should not be able to send instructions if the user if not locked and have username as unlock key' do
|
222
222
|
swap Devise, unlock_keys: [:username] do
|
223
223
|
user = create_user
|
224
|
-
|
225
|
-
|
224
|
+
refute user.resend_unlock_instructions
|
225
|
+
refute user.access_locked?
|
226
226
|
assert_equal 'was not locked', user.errors[:username].join
|
227
227
|
end
|
228
228
|
end
|
@@ -257,7 +257,7 @@ class LockableTest < ActiveSupport::TestCase
|
|
257
257
|
test 'required_fields should contain the all the fields when all the strategies are enabled' do
|
258
258
|
swap Devise, unlock_strategy: :both do
|
259
259
|
swap Devise, lock_strategy: :failed_attempts do
|
260
|
-
|
260
|
+
assert_equal Devise::Models::Lockable.required_fields(User), [
|
261
261
|
:failed_attempts,
|
262
262
|
:locked_at,
|
263
263
|
:unlock_token
|
@@ -269,7 +269,7 @@ class LockableTest < ActiveSupport::TestCase
|
|
269
269
|
test 'required_fields should contain only failed_attempts and locked_at when the strategies are time and failed_attempts are enabled' do
|
270
270
|
swap Devise, unlock_strategy: :time do
|
271
271
|
swap Devise, lock_strategy: :failed_attempts do
|
272
|
-
|
272
|
+
assert_equal Devise::Models::Lockable.required_fields(User), [
|
273
273
|
:failed_attempts,
|
274
274
|
:locked_at
|
275
275
|
]
|
@@ -280,7 +280,7 @@ class LockableTest < ActiveSupport::TestCase
|
|
280
280
|
test 'required_fields should contain only failed_attempts and unlock_token when the strategies are token and failed_attempts are enabled' do
|
281
281
|
swap Devise, unlock_strategy: :email do
|
282
282
|
swap Devise, lock_strategy: :failed_attempts do
|
283
|
-
|
283
|
+
assert_equal Devise::Models::Lockable.required_fields(User), [
|
284
284
|
:failed_attempts,
|
285
285
|
:unlock_token
|
286
286
|
]
|
@@ -2,6 +2,6 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class OmniauthableTest < ActiveSupport::TestCase
|
4
4
|
test 'required_fields should contain the fields that Devise uses' do
|
5
|
-
|
5
|
+
assert_equal Devise::Models::Omniauthable.required_fields(User), []
|
6
6
|
end
|
7
7
|
end
|
@@ -92,14 +92,14 @@ class RecoverableTest < ActiveSupport::TestCase
|
|
92
92
|
user = create_user
|
93
93
|
user.send_reset_password_instructions
|
94
94
|
assert_present user.reset_password_token
|
95
|
-
|
95
|
+
refute user.reset_password('123456789', '987654321')
|
96
96
|
assert_present user.reset_password_token
|
97
97
|
end
|
98
98
|
|
99
99
|
test 'should not reset password with invalid data' do
|
100
100
|
user = create_user
|
101
101
|
user.stubs(:valid?).returns(false)
|
102
|
-
|
102
|
+
refute user.reset_password('123456789', '987654321')
|
103
103
|
end
|
104
104
|
|
105
105
|
test 'should reset reset password token and send instructions by email' do
|
@@ -119,7 +119,7 @@ class RecoverableTest < ActiveSupport::TestCase
|
|
119
119
|
|
120
120
|
test 'should return a new record with errors if user was not found by e-mail' do
|
121
121
|
reset_password_user = User.send_reset_password_instructions(email: "invalid@example.com")
|
122
|
-
|
122
|
+
refute reset_password_user.persisted?
|
123
123
|
assert_equal "not found", reset_password_user.errors[:email].join
|
124
124
|
end
|
125
125
|
|
@@ -135,7 +135,7 @@ class RecoverableTest < ActiveSupport::TestCase
|
|
135
135
|
swap Devise, reset_password_keys: [:username, :email] do
|
136
136
|
user = create_user
|
137
137
|
reset_password_user = User.send_reset_password_instructions(email: user.email)
|
138
|
-
|
138
|
+
refute reset_password_user.persisted?
|
139
139
|
assert_equal "can't be blank", reset_password_user.errors[:username].join
|
140
140
|
end
|
141
141
|
end
|
@@ -164,13 +164,13 @@ class RecoverableTest < ActiveSupport::TestCase
|
|
164
164
|
|
165
165
|
test 'should return a new record with errors if no reset_password_token is found' do
|
166
166
|
reset_password_user = User.reset_password_by_token(reset_password_token: 'invalid_token')
|
167
|
-
|
167
|
+
refute reset_password_user.persisted?
|
168
168
|
assert_equal "is invalid", reset_password_user.errors[:reset_password_token].join
|
169
169
|
end
|
170
170
|
|
171
171
|
test 'should return a new record with errors if reset_password_token is blank' do
|
172
172
|
reset_password_user = User.reset_password_by_token(reset_password_token: '')
|
173
|
-
|
173
|
+
refute reset_password_user.persisted?
|
174
174
|
assert_match "can't be blank", reset_password_user.errors[:reset_password_token].join
|
175
175
|
end
|
176
176
|
|
@@ -179,7 +179,7 @@ class RecoverableTest < ActiveSupport::TestCase
|
|
179
179
|
raw = user.send_reset_password_instructions
|
180
180
|
|
181
181
|
reset_password_user = User.reset_password_by_token(reset_password_token: raw, password: '')
|
182
|
-
|
182
|
+
refute reset_password_user.errors.empty?
|
183
183
|
assert_match "can't be blank", reset_password_user.errors[:password].join
|
184
184
|
assert_equal raw, reset_password_user.reset_password_token
|
185
185
|
end
|
@@ -197,7 +197,7 @@ class RecoverableTest < ActiveSupport::TestCase
|
|
197
197
|
assert_nil reset_password_user.reset_password_token
|
198
198
|
|
199
199
|
user.reload
|
200
|
-
|
200
|
+
refute user.valid_password?(old_password)
|
201
201
|
assert user.valid_password?('new_password')
|
202
202
|
assert_nil user.reset_password_token
|
203
203
|
end
|
@@ -219,13 +219,13 @@ class RecoverableTest < ActiveSupport::TestCase
|
|
219
219
|
user.reload
|
220
220
|
|
221
221
|
assert user.valid_password?(old_password)
|
222
|
-
|
222
|
+
refute user.valid_password?('new_password')
|
223
223
|
assert_equal "has expired, please request a new one", reset_password_user.errors[:reset_password_token].join
|
224
224
|
end
|
225
225
|
end
|
226
226
|
|
227
227
|
test 'required_fields should contain the fields that Devise uses' do
|
228
|
-
|
228
|
+
assert_equal Devise::Models::Recoverable.required_fields(User), [
|
229
229
|
:reset_password_sent_at,
|
230
230
|
:reset_password_token
|
231
231
|
]
|
@@ -2,6 +2,6 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class RegisterableTest < ActiveSupport::TestCase
|
4
4
|
test 'required_fields should contain the fields that Devise uses' do
|
5
|
-
|
5
|
+
assert_equal Devise::Models::Registerable.required_fields(User), []
|
6
6
|
end
|
7
7
|
end
|
@@ -99,15 +99,28 @@ class RememberableTest < ActiveSupport::TestCase
|
|
99
99
|
assert_nil User.serialize_from_cookie(user.to_key, "123", Time.now.utc)
|
100
100
|
end
|
101
101
|
|
102
|
+
test 'raises a RuntimeError if the user does not implements a rememberable value' do
|
103
|
+
user = User.new
|
104
|
+
assert_raise(RuntimeError) { user.rememberable_value }
|
105
|
+
|
106
|
+
user_with_remember_token = User.new
|
107
|
+
def user_with_remember_token.remember_token; '123-token'; end
|
108
|
+
assert_equal '123-token', user_with_remember_token.rememberable_value
|
109
|
+
|
110
|
+
user_with_salt = User.new
|
111
|
+
def user_with_salt.authenticatable_salt; '123-salt'; end
|
112
|
+
assert_equal '123-salt', user_with_salt.rememberable_value
|
113
|
+
end
|
114
|
+
|
102
115
|
test 'raises a RuntimeError if authenticatable_salt is nil or empty' do
|
103
116
|
user = User.new
|
104
|
-
def user.
|
117
|
+
def user.authenticatable_salt; nil; end
|
105
118
|
assert_raise RuntimeError do
|
106
119
|
user.rememberable_value
|
107
120
|
end
|
108
121
|
|
109
122
|
user = User.new
|
110
|
-
def user.
|
123
|
+
def user.authenticatable_salt; ""; end
|
111
124
|
assert_raise RuntimeError do
|
112
125
|
user.rememberable_value
|
113
126
|
end
|
@@ -162,7 +175,7 @@ class RememberableTest < ActiveSupport::TestCase
|
|
162
175
|
end
|
163
176
|
|
164
177
|
test 'should have the required_fields array' do
|
165
|
-
|
178
|
+
assert_equal Devise::Models::Rememberable.required_fields(User), [
|
166
179
|
:remember_created_at
|
167
180
|
]
|
168
181
|
end
|
@@ -35,6 +35,11 @@ class SerializableTest < ActiveSupport::TestCase
|
|
35
35
|
assert_key "confirmation_token", from_json(force_except: :email)
|
36
36
|
end
|
37
37
|
|
38
|
+
test 'should not include unsafe keys in inspect' do
|
39
|
+
assert_match(/email/, @user.inspect)
|
40
|
+
assert_no_match(/confirmation_token/, @user.inspect)
|
41
|
+
end
|
42
|
+
|
38
43
|
def assert_key(key, subject)
|
39
44
|
assert subject.key?(key), "Expected #{subject.inspect} to have key #{key.inspect}"
|
40
45
|
end
|
@@ -7,11 +7,11 @@ class TimeoutableTest < ActiveSupport::TestCase
|
|
7
7
|
end
|
8
8
|
|
9
9
|
test 'should not be expired' do
|
10
|
-
|
10
|
+
refute new_user.timedout?(29.minutes.ago)
|
11
11
|
end
|
12
12
|
|
13
13
|
test 'should not be expired when params is nil' do
|
14
|
-
|
14
|
+
refute new_user.timedout?(nil)
|
15
15
|
end
|
16
16
|
|
17
17
|
test 'should use timeout_in method' do
|
@@ -19,29 +19,29 @@ class TimeoutableTest < ActiveSupport::TestCase
|
|
19
19
|
user.instance_eval { def timeout_in; 10.minutes end }
|
20
20
|
|
21
21
|
assert user.timedout?(12.minutes.ago)
|
22
|
-
|
22
|
+
refute user.timedout?(8.minutes.ago)
|
23
23
|
end
|
24
24
|
|
25
25
|
test 'should not be expired when timeout_in method returns nil' do
|
26
26
|
user = new_user
|
27
27
|
user.instance_eval { def timeout_in; nil end }
|
28
|
-
|
28
|
+
refute user.timedout?(10.hours.ago)
|
29
29
|
end
|
30
30
|
|
31
31
|
test 'fallback to Devise config option' do
|
32
32
|
swap Devise, timeout_in: 1.minute do
|
33
33
|
user = new_user
|
34
34
|
assert user.timedout?(2.minutes.ago)
|
35
|
-
|
35
|
+
refute user.timedout?(30.seconds.ago)
|
36
36
|
|
37
37
|
Devise.timeout_in = 5.minutes
|
38
|
-
|
38
|
+
refute user.timedout?(2.minutes.ago)
|
39
39
|
assert user.timedout?(6.minutes.ago)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
test 'required_fields should contain the fields that Devise uses' do
|
44
|
-
|
44
|
+
assert_equal Devise::Models::Timeoutable.required_fields(User), []
|
45
45
|
end
|
46
46
|
|
47
47
|
test 'should not raise error if remember_created_at is not empty and rememberable is disabled' do
|
@@ -2,7 +2,7 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class TrackableTest < ActiveSupport::TestCase
|
4
4
|
test 'required_fields should contain the fields that Devise uses' do
|
5
|
-
|
5
|
+
assert_equal Devise::Models::Trackable.required_fields(User), [
|
6
6
|
:current_sign_in_at,
|
7
7
|
:current_sign_in_ip,
|
8
8
|
:last_sign_in_at,
|
@@ -97,7 +97,7 @@ class ValidatableTest < ActiveSupport::TestCase
|
|
97
97
|
|
98
98
|
user.password_confirmation = 'confirmation'
|
99
99
|
assert user.invalid?
|
100
|
-
|
100
|
+
refute (user.errors[:password].join =~ /is too long/)
|
101
101
|
end
|
102
102
|
|
103
103
|
test 'should complain about length even if password is not required' do
|
data/test/models_test.rb
CHANGED
@@ -13,7 +13,7 @@ class ActiveRecordTest < ActiveSupport::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
(Devise::ALL - modules).each do |mod|
|
16
|
-
|
16
|
+
refute include_module?(klass, mod)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -112,7 +112,7 @@ class CheckFieldsTest < ActiveSupport::TestCase
|
|
112
112
|
attr_accessor :encrypted_password, :email
|
113
113
|
end
|
114
114
|
|
115
|
-
assert_nothing_raised
|
115
|
+
assert_nothing_raised do
|
116
116
|
Devise::Models.check_fields!(Player)
|
117
117
|
end
|
118
118
|
end
|