devise 4.2.0 → 4.2.1
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 -4
- data/CHANGELOG.md +14 -1
- data/CONTRIBUTING.md +68 -28
- data/Gemfile.lock +69 -74
- data/README.md +10 -6
- data/app/controllers/devise/registrations_controller.rb +1 -0
- data/app/mailers/devise/mailer.rb +4 -0
- data/app/views/devise/mailer/email_changed.html.erb +7 -0
- data/config/locales/en.yml +2 -0
- data/gemfiles/Gemfile.rails-4.1-stable.lock +65 -68
- data/gemfiles/Gemfile.rails-4.2-stable.lock +65 -70
- data/lib/devise.rb +5 -1
- data/lib/devise/controllers/store_location.rb +1 -1
- data/lib/devise/failure_app.rb +12 -12
- data/lib/devise/hooks/lockable.rb +4 -1
- data/lib/devise/mailers/helpers.rb +4 -3
- data/lib/devise/models.rb +1 -1
- data/lib/devise/models/confirmable.rb +14 -2
- data/lib/devise/models/database_authenticatable.rb +16 -1
- data/lib/devise/models/recoverable.rb +8 -4
- data/lib/devise/models/rememberable.rb +1 -1
- data/lib/devise/rails/routes.rb +1 -1
- data/lib/devise/test/controller_helpers.rb +1 -1
- data/lib/devise/test_helpers.rb +1 -1
- data/lib/devise/version.rb +1 -1
- data/lib/generators/templates/controllers/registrations_controller.rb +2 -2
- data/lib/generators/templates/controllers/sessions_controller.rb +1 -1
- data/lib/generators/templates/devise.rb +4 -1
- data/lib/generators/templates/markerb/email_changed.markerb +7 -0
- data/lib/generators/templates/markerb/password_change.markerb +2 -2
- data/test/controllers/helpers_test.rb +3 -3
- data/test/integration/authenticatable_test.rb +1 -1
- data/test/mailers/email_changed_test.rb +130 -0
- data/test/mailers/mailer_test.rb +18 -0
- data/test/models/confirmable_test.rb +17 -0
- data/test/models/database_authenticatable_test.rb +13 -1
- data/test/models/recoverable_test.rb +11 -1
- data/test/omniauth/config_test.rb +9 -7
- metadata +9 -3
@@ -0,0 +1,18 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class MailerTest < ActionMailer::TestCase
|
4
|
+
test "pass given block to #mail call" do
|
5
|
+
class TestMailer < Devise::Mailer
|
6
|
+
def confirmation_instructions(record, token, opts = {})
|
7
|
+
@token = token
|
8
|
+
devise_mail(record, :confirmation_instructions, opts) do |format|
|
9
|
+
format.html(content_transfer_encoding: "7bit")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
mail = TestMailer.confirmation_instructions(create_user, "confirmation-token")
|
15
|
+
|
16
|
+
assert mail.content_transfer_encoding, "7bit"
|
17
|
+
end
|
18
|
+
end
|
@@ -516,4 +516,21 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
|
516
516
|
admin.save
|
517
517
|
assert admin.pending_reconfirmation?
|
518
518
|
end
|
519
|
+
|
520
|
+
test 'should notify previous email on email change when configured' do
|
521
|
+
swap Devise, send_email_changed_notification: true do
|
522
|
+
admin = create_admin
|
523
|
+
original_email = admin.email
|
524
|
+
|
525
|
+
assert_difference 'ActionMailer::Base.deliveries.size', 2 do
|
526
|
+
assert admin.update_attributes(email: 'new-email@example.com')
|
527
|
+
end
|
528
|
+
assert_equal original_email, ActionMailer::Base.deliveries[-2]['to'].to_s
|
529
|
+
assert_equal 'new-email@example.com', ActionMailer::Base.deliveries[-1]['to'].to_s
|
530
|
+
|
531
|
+
assert_email_not_sent do
|
532
|
+
assert admin.confirm
|
533
|
+
end
|
534
|
+
end
|
535
|
+
end
|
519
536
|
end
|
@@ -236,12 +236,24 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
|
236
236
|
end
|
237
237
|
end
|
238
238
|
|
239
|
-
test 'should email on
|
239
|
+
test 'should notify previous email on email change when configured' do
|
240
|
+
swap Devise, send_email_changed_notification: true do
|
241
|
+
user = create_user
|
242
|
+
original_email = user.email
|
243
|
+
assert_email_sent original_email do
|
244
|
+
assert user.update_attributes(email: 'new-email@example.com')
|
245
|
+
end
|
246
|
+
assert_match original_email, ActionMailer::Base.deliveries.last.body.encoded
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
test 'should notify email on password change when configured' do
|
240
251
|
swap Devise, send_password_change_notification: true do
|
241
252
|
user = create_user
|
242
253
|
assert_email_sent user.email do
|
243
254
|
assert user.update_attributes(password: 'newpass', password_confirmation: 'newpass')
|
244
255
|
end
|
256
|
+
assert_match user.email, ActionMailer::Base.deliveries.last.body.encoded
|
245
257
|
end
|
246
258
|
end
|
247
259
|
|
@@ -184,6 +184,16 @@ class RecoverableTest < ActiveSupport::TestCase
|
|
184
184
|
assert_equal raw, reset_password_user.reset_password_token
|
185
185
|
end
|
186
186
|
|
187
|
+
test 'should return a new record with errors if password is not provided' do
|
188
|
+
user = create_user
|
189
|
+
raw = user.send_reset_password_instructions
|
190
|
+
|
191
|
+
reset_password_user = User.reset_password_by_token(reset_password_token: raw)
|
192
|
+
refute reset_password_user.errors.empty?
|
193
|
+
assert_match "can't be blank", reset_password_user.errors[:password].join
|
194
|
+
assert_equal raw, reset_password_user.reset_password_token
|
195
|
+
end
|
196
|
+
|
187
197
|
test 'should reset successfully user password given the new password and confirmation' do
|
188
198
|
user = create_user
|
189
199
|
old_password = user.password
|
@@ -245,7 +255,7 @@ class RecoverableTest < ActiveSupport::TestCase
|
|
245
255
|
end
|
246
256
|
|
247
257
|
test 'should return nil if a user based on the raw token is not found' do
|
248
|
-
|
258
|
+
assert_nil User.with_reset_password_token('random-token')
|
249
259
|
end
|
250
260
|
|
251
261
|
end
|
@@ -25,19 +25,21 @@ class OmniAuthConfigTest < ActiveSupport::TestCase
|
|
25
25
|
assert_equal OmniAuth::Strategies::Facebook, config.strategy_class
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
class NamedTestStrategy
|
29
|
+
include OmniAuth::Strategy
|
30
|
+
option :name, :the_one
|
31
|
+
end
|
32
32
|
|
33
|
+
test "finds the strategy in OmniAuth's list by name" do
|
33
34
|
config = Devise::OmniAuth::Config.new :the_one, [{}]
|
34
35
|
assert_equal NamedTestStrategy, config.strategy_class
|
35
36
|
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
class UnNamedTestStrategy
|
39
|
+
include OmniAuth::Strategy
|
40
|
+
end
|
40
41
|
|
42
|
+
test "finds the strategy in OmniAuth's list by class name" do
|
41
43
|
config = Devise::OmniAuth::Config.new :un_named_test_strategy, [{}]
|
42
44
|
assert_equal UnNamedTestStrategy, config.strategy_class
|
43
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Valim
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-03-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: warden
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- app/mailers/devise/mailer.rb
|
116
116
|
- app/views/devise/confirmations/new.html.erb
|
117
117
|
- app/views/devise/mailer/confirmation_instructions.html.erb
|
118
|
+
- app/views/devise/mailer/email_changed.html.erb
|
118
119
|
- app/views/devise/mailer/password_change.html.erb
|
119
120
|
- app/views/devise/mailer/reset_password_instructions.html.erb
|
120
121
|
- app/views/devise/mailer/unlock_instructions.html.erb
|
@@ -206,6 +207,7 @@ files:
|
|
206
207
|
- lib/generators/templates/controllers/unlocks_controller.rb
|
207
208
|
- lib/generators/templates/devise.rb
|
208
209
|
- lib/generators/templates/markerb/confirmation_instructions.markerb
|
210
|
+
- lib/generators/templates/markerb/email_changed.markerb
|
209
211
|
- lib/generators/templates/markerb/password_change.markerb
|
210
212
|
- lib/generators/templates/markerb/reset_password_instructions.markerb
|
211
213
|
- lib/generators/templates/markerb/unlock_instructions.markerb
|
@@ -249,6 +251,8 @@ files:
|
|
249
251
|
- test/integration/timeoutable_test.rb
|
250
252
|
- test/integration/trackable_test.rb
|
251
253
|
- test/mailers/confirmation_instructions_test.rb
|
254
|
+
- test/mailers/email_changed_test.rb
|
255
|
+
- test/mailers/mailer_test.rb
|
252
256
|
- test/mailers/reset_password_instructions_test.rb
|
253
257
|
- test/mailers/unlock_instructions_test.rb
|
254
258
|
- test/mapping_test.rb
|
@@ -370,7 +374,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
370
374
|
version: '0'
|
371
375
|
requirements: []
|
372
376
|
rubyforge_project:
|
373
|
-
rubygems_version: 2.5.
|
377
|
+
rubygems_version: 2.5.2
|
374
378
|
signing_key:
|
375
379
|
specification_version: 4
|
376
380
|
summary: Flexible authentication solution for Rails with Warden
|
@@ -408,6 +412,8 @@ test_files:
|
|
408
412
|
- test/integration/timeoutable_test.rb
|
409
413
|
- test/integration/trackable_test.rb
|
410
414
|
- test/mailers/confirmation_instructions_test.rb
|
415
|
+
- test/mailers/email_changed_test.rb
|
416
|
+
- test/mailers/mailer_test.rb
|
411
417
|
- test/mailers/reset_password_instructions_test.rb
|
412
418
|
- test/mailers/unlock_instructions_test.rb
|
413
419
|
- test/mapping_test.rb
|