goma 0.0.1.rc1 → 0.0.1.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/Gemfile.lock +1 -1
- data/Rakefile +6 -0
- data/goma.gemspec +0 -5
- data/lib/goma/config.rb +3 -3
- data/lib/goma/models/confirmable.rb +2 -3
- data/lib/goma/models/lockable.rb +1 -0
- data/lib/goma/models/omniauthable.rb +9 -2
- data/lib/goma/models/password_authenticatable.rb +1 -1
- data/lib/goma/models/timeoutable.rb +1 -1
- data/lib/goma/models/validatable.rb +1 -1
- data/lib/goma/version.rb +1 -1
- data/test/fabricators/authentication_fabricator.rb +4 -0
- data/test/fabricators/{users_fabricator.rb → user_fabricator.rb} +8 -0
- data/test/integration/confirmable_integration_test.rb +5 -5
- data/test/integration/lockable_integration_test.rb +1 -1
- data/test/integration/recoverable_integration_test.rb +2 -2
- data/test/integration/timeoutable_integration_test.rb +171 -171
- data/test/models/confirmable_test.rb +207 -159
- data/test/{goma_test.rb → models/goma_test.rb} +0 -5
- data/test/models/lockable_test.rb +131 -0
- data/test/models/recoverable_test.rb +108 -0
- data/test/models/rememberable_test.rb +115 -0
- data/test/models/timeoutable_test.rb +33 -0
- data/test/models/trackable_test.rb +37 -0
- data/test/models/validatable_test.rb +131 -35
- data/test/rails_app/config/initializers/goma.rb +1 -1
- data/test/rails_app/db/migrate/20140515111009_create_users.rb +1 -0
- data/test/rails_app/db/schema.rb +1 -0
- data/test/test_helper.rb +1 -0
- metadata +19 -13
- data/test/config_test.rb +0 -2
@@ -1,227 +1,275 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
3
|
class ConfirmableTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
test 'should not be activated when user is created' do
|
5
|
+
user = User.create(username: 'foo', email: 'foo@example.com', password: 'password')
|
6
|
+
user.reload
|
7
|
+
refute user.activated?
|
8
|
+
end
|
9
|
+
|
10
|
+
test 'should send activation needed email when user is created' do
|
11
|
+
Goma.token_generator.expects(:friendly_token).returns('sesame')
|
8
12
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
refute @user.activated?
|
13
|
+
user = User.new(username: 'foo', email: 'foo@example.com', password: 'password')
|
14
|
+
assert_emails 1 do
|
15
|
+
user.save!
|
13
16
|
end
|
17
|
+
email = ActionMailer::Base.deliveries.last
|
18
|
+
assert_match %r{/confirmations/sesame}, email.body.encoded
|
19
|
+
end
|
14
20
|
|
15
|
-
|
16
|
-
|
17
|
-
|
21
|
+
test 'should not send activation needed email when user is created if activation_needed_email_method_name == nil' do
|
22
|
+
swap Goma.config(:user), activation_needed_email_method_name: nil do
|
23
|
+
user = User.new(username: 'foo', email: 'foo@example.com', password: 'password')
|
24
|
+
assert_no_emails do
|
25
|
+
user.save!
|
18
26
|
end
|
19
27
|
end
|
20
28
|
end
|
21
29
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
30
|
+
test 'load_from_activation_token_with_error with correct token' do
|
31
|
+
user = Fabricate(:unactivated_user)
|
32
|
+
raw_token = user.raw_confirmation_token
|
33
|
+
loaded_user, error = User.load_from_activation_token_with_error(raw_token)
|
34
|
+
assert_equal user, loaded_user
|
35
|
+
assert_nil error
|
36
|
+
end
|
26
37
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
38
|
+
test 'load_from_activation_token_with_error with wrong token' do
|
39
|
+
user = Fabricate(:unactivated_user)
|
40
|
+
loaded_user, error = User.load_from_activation_token_with_error('beans')
|
41
|
+
assert_nil loaded_user
|
42
|
+
assert_equal :not_found, error
|
43
|
+
end
|
32
44
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
45
|
+
test 'load_from_activation_token_with_error with expired token' do
|
46
|
+
user = Fabricate(:unactivated_user)
|
47
|
+
raw_token = user.raw_confirmation_token
|
48
|
+
Timecop.travel 4.days.from_now do
|
49
|
+
loaded_user, error = User.load_from_activation_token_with_error(raw_token)
|
50
|
+
assert_nil loaded_user
|
51
|
+
assert_equal :token_expired, error
|
37
52
|
end
|
53
|
+
end
|
38
54
|
|
39
|
-
|
40
|
-
|
41
|
-
|
55
|
+
test 'load_from_activation_token! with correct token' do
|
56
|
+
user = Fabricate(:unactivated_user)
|
57
|
+
raw_token = user.raw_confirmation_token
|
58
|
+
assert_equal user, User.load_from_activation_token!(raw_token)
|
59
|
+
end
|
42
60
|
|
61
|
+
test 'load_from_activation_token! with wrong token' do
|
62
|
+
user = Fabricate(:unactivated_user)
|
63
|
+
assert_raise Goma::NotFound do
|
64
|
+
User.load_from_activation_token!('beans')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
test 'load_from_activation_token! with expired token' do
|
69
|
+
user = Fabricate(:unactivated_user)
|
70
|
+
raw_token = user.raw_confirmation_token
|
71
|
+
Timecop.travel 4.days.from_now do
|
43
72
|
assert_raise Goma::TokenExpired do
|
44
73
|
User.load_from_activation_token!(raw_token)
|
45
74
|
end
|
46
75
|
end
|
47
76
|
end
|
48
77
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
78
|
+
test 'load_from_activation_token with correct token' do
|
79
|
+
user = Fabricate(:unactivated_user)
|
80
|
+
raw_token = user.raw_confirmation_token
|
81
|
+
assert_equal user, User.load_from_activation_token(raw_token)
|
82
|
+
end
|
53
83
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
assert_nil error
|
59
|
-
end
|
84
|
+
test 'load_from_activation_token with wrong token' do
|
85
|
+
user = Fabricate(:unactivated_user)
|
86
|
+
assert_nil User.load_from_activation_token('beans')
|
87
|
+
end
|
60
88
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
89
|
+
test 'load_from_activation_token with expired token' do
|
90
|
+
user = Fabricate(:unactivated_user)
|
91
|
+
raw_token = user.raw_confirmation_token
|
92
|
+
Timecop.travel 4.days.from_now do
|
93
|
+
assert_nil User.load_from_activation_token(raw_token)
|
65
94
|
end
|
95
|
+
end
|
66
96
|
|
67
|
-
|
68
|
-
|
69
|
-
|
97
|
+
test 'activate!' do
|
98
|
+
user = Fabricate(:unactivated_user)
|
99
|
+
refute user.activated?
|
70
100
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
101
|
+
user.activate!
|
102
|
+
user.reload
|
103
|
+
assert user.activated?
|
104
|
+
assert_nil user.confirmation_token
|
105
|
+
assert_nil user.confirmation_token_sent_at
|
75
106
|
end
|
76
107
|
|
77
|
-
|
78
|
-
|
79
|
-
|
108
|
+
test 'should send activation success email when activating' do
|
109
|
+
user = Fabricate(:unactivated_user)
|
110
|
+
assert_emails 1 do
|
111
|
+
user.activate!
|
80
112
|
end
|
113
|
+
email = ActionMailer::Base.deliveries.last
|
114
|
+
assert_match /You have successfully activated your account/, email.body.encoded
|
115
|
+
end
|
81
116
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
117
|
+
test 'should not send activation success email when activating if activation_success_email_method_name == nil' do
|
118
|
+
swap Goma.config(:user), activation_success_email_method_name: nil do
|
119
|
+
user = Fabricate(:unactivated_user)
|
120
|
+
assert_no_emails do
|
121
|
+
user.activate!
|
122
|
+
end
|
86
123
|
end
|
124
|
+
end
|
87
125
|
|
88
|
-
|
89
|
-
|
90
|
-
|
126
|
+
test 'should change email immediately if email_confirmation_enabled == false' do
|
127
|
+
swap Goma.config(:user), email_confirmation_enabled: false do
|
128
|
+
user = Fabricate(:user)
|
129
|
+
user.update(email: 'new@example.com')
|
130
|
+
user.reload
|
131
|
+
assert_equal 'new@example.com', user.email
|
91
132
|
end
|
133
|
+
end
|
92
134
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
135
|
+
test 'should postpone email change' do
|
136
|
+
user = Fabricate(:user)
|
137
|
+
old_email = user.email
|
138
|
+
user.update(email: 'new@example.com')
|
139
|
+
user.reload
|
140
|
+
assert_equal old_email, user.email
|
141
|
+
assert_equal 'new@example.com', user.unconfirmed_email
|
142
|
+
assert user.confirmation_token
|
143
|
+
assert user.confirmation_token_sent_at
|
100
144
|
end
|
101
145
|
|
102
|
-
|
103
|
-
|
104
|
-
@user = Fabricate(:unactivated_user)
|
105
|
-
end
|
146
|
+
test 'should send email confirmation needed email when email is changed' do
|
147
|
+
Goma.token_generator.stubs(:friendly_token).returns('sesame')
|
106
148
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
@user.reload
|
111
|
-
assert @user.activated_at
|
149
|
+
user = Fabricate(:user)
|
150
|
+
assert_emails 1 do
|
151
|
+
user.update(email: 'new@example.com')
|
112
152
|
end
|
153
|
+
email = ActionMailer::Base.deliveries.last
|
154
|
+
assert_match %r{/confirmations/sesame/email}, email.body.encoded
|
155
|
+
end
|
113
156
|
|
114
|
-
|
115
|
-
|
116
|
-
|
157
|
+
test 'should not send email confirmation needed email when email is changed if email_confirmation_needed_email_method_name == nil' do
|
158
|
+
swap Goma.config(:user), email_confirmation_needed_email_method_name: nil do
|
159
|
+
user = Fabricate(:user)
|
160
|
+
assert_no_emails do
|
161
|
+
user.update(email: 'new@example.com')
|
117
162
|
end
|
118
163
|
end
|
119
164
|
end
|
120
165
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
@user.save!
|
130
|
-
assert_equal @old_email, @user.email
|
131
|
-
assert_equal 'another@example.com', @user.unconfirmed_email
|
132
|
-
end
|
166
|
+
test 'load_from_email_confirmation_token_with_error with correct token' do
|
167
|
+
user = Fabricate(:user)
|
168
|
+
user.update(email: 'new@example.com')
|
169
|
+
raw_token = user.raw_confirmation_token
|
170
|
+
loaded_user, error = User.load_from_email_confirmation_token_with_error(raw_token)
|
171
|
+
assert_equal user, loaded_user
|
172
|
+
assert_nil error
|
173
|
+
end
|
133
174
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
175
|
+
test 'load_from_email_confirmation_token_with_error with wrong token' do
|
176
|
+
user = Fabricate(:user)
|
177
|
+
user.update(email: 'new@example.com')
|
178
|
+
loaded_user, error = User.load_from_email_confirmation_token_with_error('beans')
|
179
|
+
assert_nil loaded_user
|
180
|
+
assert_equal :not_found, error
|
139
181
|
end
|
140
182
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
183
|
+
test 'load_from_email_confirmation_token_with_error with expired token' do
|
184
|
+
user = Fabricate(:user)
|
185
|
+
user.update(email: 'new@example.com')
|
186
|
+
raw_token = user.raw_confirmation_token
|
187
|
+
Timecop.travel 4.days.from_now do
|
188
|
+
loaded_user, error = User.load_from_email_confirmation_token_with_error(raw_token)
|
189
|
+
assert_nil loaded_user
|
190
|
+
assert_equal :token_expired, error
|
146
191
|
end
|
192
|
+
end
|
147
193
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
194
|
+
test 'load_from_email_confirmation_token! with correct token' do
|
195
|
+
user = Fabricate(:user)
|
196
|
+
user.update(email: 'new@example.com')
|
197
|
+
raw_token = user.raw_confirmation_token
|
198
|
+
assert_equal user, User.load_from_email_confirmation_token!(raw_token)
|
199
|
+
end
|
153
200
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
201
|
+
test 'load_from_email_confirmation_token! with wrong token' do
|
202
|
+
user = Fabricate(:user)
|
203
|
+
user.update(email: 'new@example.com')
|
204
|
+
assert_raise Goma::NotFound do
|
205
|
+
User.load_from_email_confirmation_token!('beans')
|
158
206
|
end
|
207
|
+
end
|
159
208
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
209
|
+
test 'load_from_email_confirmation_token! with expired token' do
|
210
|
+
user = Fabricate(:user)
|
211
|
+
user.update(email: 'new@example.com')
|
212
|
+
raw_token = user.raw_confirmation_token
|
213
|
+
Timecop.travel 4.days.from_now do
|
164
214
|
assert_raise Goma::TokenExpired do
|
165
215
|
User.load_from_email_confirmation_token!(raw_token)
|
166
216
|
end
|
167
217
|
end
|
168
218
|
end
|
169
219
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
should "return user record and nil with correct email_confirmation token" do
|
178
|
-
raw_token = @user.raw_confirmation_token
|
179
|
-
loaded_user, error = User.load_from_email_confirmation_token_with_error(raw_token)
|
180
|
-
assert_equal @user, loaded_user
|
181
|
-
assert_nil error
|
182
|
-
end
|
183
|
-
|
184
|
-
should "return nil and :not_found with incorrect email_confirmation token" do
|
185
|
-
loaded_user, error = User.load_from_email_confirmation_token_with_error('blahblahblah')
|
186
|
-
assert_nil loaded_user
|
187
|
-
assert_equal :not_found, error
|
188
|
-
end
|
189
|
-
|
190
|
-
should "return nil and :token_expired with correct email_confirmation token which is expired" do
|
191
|
-
raw_token = @user.raw_confirmation_token
|
192
|
-
@user.update_attribute(:confirmation_token_sent_at, 7.days.ago)
|
220
|
+
test 'load_from_email_confirmation_token with correct token' do
|
221
|
+
user = Fabricate(:user)
|
222
|
+
user.update(email: 'new@example.com')
|
223
|
+
raw_token = user.raw_confirmation_token
|
224
|
+
assert_equal user, User.load_from_email_confirmation_token(raw_token)
|
225
|
+
end
|
193
226
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
227
|
+
test 'load_from_email_confirmation_token with wrong token' do
|
228
|
+
user = Fabricate(:user)
|
229
|
+
user.update(email: 'new@example.com')
|
230
|
+
assert_nil User.load_from_email_confirmation_token('beans')
|
198
231
|
end
|
199
232
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
233
|
+
test 'load_from_email_confirmation_token with expired token' do
|
234
|
+
user = Fabricate(:user)
|
235
|
+
user.update(email: 'new@example.com')
|
236
|
+
raw_token = user.raw_confirmation_token
|
237
|
+
Timecop.travel 4.days.from_now do
|
238
|
+
assert_nil User.load_from_email_confirmation_token(raw_token)
|
205
239
|
end
|
240
|
+
end
|
206
241
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
242
|
+
test 'confirm_email!' do
|
243
|
+
user = Fabricate(:user)
|
244
|
+
user.update(email: 'new@example.com')
|
245
|
+
user.reload
|
246
|
+
user.confirm_email!
|
247
|
+
user.reload
|
248
|
+
assert_nil user.unconfirmed_email
|
249
|
+
assert_equal 'new@example.com', user.email
|
250
|
+
assert_nil user.confirmation_token
|
251
|
+
assert_nil user.confirmation_token_sent_at
|
252
|
+
end
|
212
253
|
|
213
|
-
|
214
|
-
|
215
|
-
|
254
|
+
test 'should send confirmation success email when confirm_email!' do
|
255
|
+
user = Fabricate(:user)
|
256
|
+
user.update(email: 'new@example.com')
|
257
|
+
user.reload
|
258
|
+
assert_emails 1 do
|
259
|
+
user.confirm_email!
|
216
260
|
end
|
261
|
+
email = ActionMailer::Base.deliveries.last
|
262
|
+
assert_match /You have successfully changed your account email/, email.body.encoded
|
263
|
+
end
|
217
264
|
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
265
|
+
test 'should not send confirmation success email when confirm_email! if email_confirmation_success_email_method_name == nil' do
|
266
|
+
swap Goma.config(:user), email_confirmation_success_email_method_name: nil do
|
267
|
+
user = Fabricate(:user)
|
268
|
+
user.update(email: 'new@example.com')
|
269
|
+
user.reload
|
270
|
+
assert_no_emails do
|
271
|
+
user.confirm_email!
|
272
|
+
end
|
224
273
|
end
|
225
274
|
end
|
226
|
-
|
227
275
|
end
|
@@ -3,11 +3,6 @@ require 'test_helper'
|
|
3
3
|
class GomaTest < ActiveSupport::TestCase
|
4
4
|
test "goma class method is introduced to ActiveRecord::Base" do
|
5
5
|
assert ActiveRecord::Base.respond_to?(:goma)
|
6
|
-
# assert User.respond_to?(:goma)
|
7
|
-
|
8
|
-
# user = User.new
|
9
|
-
# assert_equal "blahblah", user.blahblah
|
10
|
-
# puts Goma.config.encryptor
|
11
6
|
end
|
12
7
|
|
13
8
|
test "should have module existence methods" do
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class LockableTest < ActiveSupport::TestCase
|
4
|
+
test 'lock_access!' do
|
5
|
+
user = Fabricate(:user)
|
6
|
+
user.lock_access!
|
7
|
+
user.reload
|
8
|
+
assert user.access_locked?
|
9
|
+
assert user.unlock_token
|
10
|
+
assert user.unlock_token_sent_at
|
11
|
+
assert user.locked_at
|
12
|
+
end
|
13
|
+
|
14
|
+
test 'should send unlock token email when lock_access!' do
|
15
|
+
Goma.token_generator.expects(:friendly_token).returns('sesame')
|
16
|
+
|
17
|
+
user = Fabricate(:user)
|
18
|
+
assert_emails 1 do
|
19
|
+
user.lock_access!
|
20
|
+
end
|
21
|
+
email = ActionMailer::Base.deliveries.last
|
22
|
+
assert_match %r{/unlocks/sesame}, email.body.encoded
|
23
|
+
end
|
24
|
+
|
25
|
+
test 'should not send unlock token email when lock_access! if unlock_strategies does not include :email' do
|
26
|
+
swap Goma.config(:user), unlock_strategies: [:time] do
|
27
|
+
user = Fabricate(:user)
|
28
|
+
assert_nil user.locked_at
|
29
|
+
locked_at = Time.now.utc
|
30
|
+
assert_no_emails do
|
31
|
+
user.lock_access!
|
32
|
+
end
|
33
|
+
user.reload
|
34
|
+
assert user.locked_at
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
test 'load_from_unlock_token_with_error with correct token' do
|
39
|
+
user = Fabricate(:user)
|
40
|
+
user.lock_access!
|
41
|
+
raw_token = user.raw_unlock_token
|
42
|
+
loaded_user, error = User.load_from_unlock_token_with_error(raw_token)
|
43
|
+
assert_equal user, loaded_user
|
44
|
+
assert_nil error
|
45
|
+
end
|
46
|
+
|
47
|
+
test 'load_from_unlock_token_with_error with wrong token' do
|
48
|
+
user = Fabricate(:user)
|
49
|
+
user.lock_access!
|
50
|
+
loaded_user, error = User.load_from_unlock_token_with_error('beans')
|
51
|
+
assert_nil loaded_user
|
52
|
+
assert_equal :not_found, error
|
53
|
+
end
|
54
|
+
|
55
|
+
test 'load_from_unlock_token! with correct token' do
|
56
|
+
user = Fabricate(:user)
|
57
|
+
user.lock_access!
|
58
|
+
raw_token = user.raw_unlock_token
|
59
|
+
assert_equal user, User.load_from_unlock_token!(raw_token)
|
60
|
+
end
|
61
|
+
|
62
|
+
test 'load_from_unlock_token! with wrong token' do
|
63
|
+
user = Fabricate(:user)
|
64
|
+
user.lock_access!
|
65
|
+
assert_raise Goma::NotFound do
|
66
|
+
User.load_from_unlock_token!('beans')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
test 'load_from_unlock_token with correct token' do
|
71
|
+
user = Fabricate(:user)
|
72
|
+
user.lock_access!
|
73
|
+
raw_token = user.raw_unlock_token
|
74
|
+
assert_equal user, User.load_from_unlock_token(raw_token)
|
75
|
+
end
|
76
|
+
|
77
|
+
test 'load_from_unlock_token with wrong token' do
|
78
|
+
user = Fabricate(:user)
|
79
|
+
user.lock_access!
|
80
|
+
assert_nil User.load_from_unlock_token('beans')
|
81
|
+
end
|
82
|
+
|
83
|
+
test 'unlock_access!' do
|
84
|
+
user = Fabricate(:user)
|
85
|
+
user.lock_access!
|
86
|
+
user.unlock_access!
|
87
|
+
user.reload
|
88
|
+
refute user.access_locked?
|
89
|
+
assert_nil user.unlock_token
|
90
|
+
assert_nil user.unlock_token_sent_at
|
91
|
+
assert_nil user.locked_at
|
92
|
+
end
|
93
|
+
|
94
|
+
test 'lock_expired?' do
|
95
|
+
user = Fabricate(:user)
|
96
|
+
user.lock_access!
|
97
|
+
user.reload
|
98
|
+
refute user.lock_expired?
|
99
|
+
Timecop.travel 1.hour.from_now
|
100
|
+
assert user.lock_expired?
|
101
|
+
Timecop.return
|
102
|
+
end
|
103
|
+
|
104
|
+
test 'valid_password?' do
|
105
|
+
swap Goma.config(:user), maximum_attempts: 3 do
|
106
|
+
user = Fabricate(:user)
|
107
|
+
3.times do
|
108
|
+
user.valid_password? 'wrongpass'
|
109
|
+
end
|
110
|
+
user.reload
|
111
|
+
refute user.access_locked?
|
112
|
+
|
113
|
+
user.valid_password? 'wrongpass'
|
114
|
+
user.reload
|
115
|
+
assert user.access_locked?
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
test 'last_attempt?' do
|
120
|
+
swap Goma.config(:user), maximum_attempts: 3 do
|
121
|
+
user = Fabricate(:user)
|
122
|
+
2.times do
|
123
|
+
user.valid_password? 'wrongpass'
|
124
|
+
refute user.last_attempt?
|
125
|
+
end
|
126
|
+
|
127
|
+
user.valid_password? 'wrongpass'
|
128
|
+
assert user.last_attempt?
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|