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.

Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/Gemfile +2 -2
  4. data/Gemfile.lock +6 -6
  5. data/README.md +7 -0
  6. data/Rakefile +1 -1
  7. data/app/controllers/devise/confirmations_controller.rb +2 -2
  8. data/app/controllers/devise/omniauth_callbacks_controller.rb +2 -2
  9. data/app/controllers/devise/passwords_controller.rb +3 -3
  10. data/app/controllers/devise/registrations_controller.rb +7 -7
  11. data/app/controllers/devise/sessions_controller.rb +6 -6
  12. data/app/controllers/devise/unlocks_controller.rb +2 -2
  13. data/app/controllers/devise_controller.rb +3 -3
  14. data/app/helpers/devise_helper.rb +2 -2
  15. data/app/views/devise/confirmations/new.html.erb +2 -2
  16. data/app/views/devise/mailer/confirmation_instructions.html.erb +1 -1
  17. data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
  18. data/app/views/devise/mailer/unlock_instructions.html.erb +1 -1
  19. data/app/views/devise/passwords/edit.html.erb +3 -3
  20. data/app/views/devise/passwords/new.html.erb +2 -2
  21. data/app/views/devise/registrations/edit.html.erb +6 -6
  22. data/app/views/devise/registrations/new.html.erb +4 -4
  23. data/app/views/devise/sessions/new.html.erb +3 -3
  24. data/app/views/devise/unlocks/new.html.erb +2 -2
  25. data/devise.gemspec +1 -1
  26. data/gemfiles/Gemfile.rails-3.2-stable +3 -3
  27. data/gemfiles/Gemfile.rails-4.0-stable +3 -3
  28. data/gemfiles/Gemfile.rails-head +3 -3
  29. data/lib/devise.rb +3 -3
  30. data/lib/devise/controllers/helpers.rb +5 -5
  31. data/lib/devise/controllers/rememberable.rb +3 -3
  32. data/lib/devise/controllers/sign_in_out.rb +8 -8
  33. data/lib/devise/failure_app.rb +3 -3
  34. data/lib/devise/hooks/activatable.rb +1 -1
  35. data/lib/devise/hooks/lockable.rb +1 -1
  36. data/lib/devise/hooks/proxy.rb +1 -1
  37. data/lib/devise/hooks/rememberable.rb +1 -1
  38. data/lib/devise/hooks/timeoutable.rb +1 -1
  39. data/lib/devise/hooks/trackable.rb +1 -1
  40. data/lib/devise/mailers/helpers.rb +8 -8
  41. data/lib/devise/models/authenticatable.rb +3 -3
  42. data/lib/devise/models/confirmable.rb +9 -9
  43. data/lib/devise/models/database_authenticatable.rb +1 -1
  44. data/lib/devise/models/lockable.rb +6 -6
  45. data/lib/devise/models/omniauthable.rb +1 -1
  46. data/lib/devise/models/recoverable.rb +1 -1
  47. data/lib/devise/models/rememberable.rb +3 -3
  48. data/lib/devise/models/trackable.rb +1 -1
  49. data/lib/devise/models/validatable.rb +6 -6
  50. data/lib/devise/modules.rb +9 -9
  51. data/lib/devise/omniauth/url_helpers.rb +2 -2
  52. data/lib/devise/rails.rb +1 -1
  53. data/lib/devise/rails/routes.rb +81 -81
  54. data/lib/devise/test_helpers.rb +2 -2
  55. data/lib/devise/time_inflector.rb +1 -1
  56. data/lib/devise/version.rb +1 -1
  57. data/lib/generators/active_record/devise_generator.rb +6 -6
  58. data/lib/generators/active_record/templates/migration.rb +4 -4
  59. data/lib/generators/active_record/templates/migration_existing.rb +4 -4
  60. data/lib/generators/devise/devise_generator.rb +3 -3
  61. data/lib/generators/devise/views_generator.rb +29 -18
  62. data/lib/generators/mongoid/devise_generator.rb +19 -19
  63. data/lib/generators/templates/README +2 -2
  64. data/lib/generators/templates/devise.rb +9 -7
  65. data/lib/generators/templates/markerb/confirmation_instructions.markerb +1 -1
  66. data/lib/generators/templates/markerb/reset_password_instructions.markerb +1 -1
  67. data/lib/generators/templates/markerb/unlock_instructions.markerb +1 -1
  68. data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +2 -2
  69. data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +4 -4
  70. data/lib/generators/templates/simple_form_for/passwords/new.html.erb +2 -2
  71. data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +6 -6
  72. data/lib/generators/templates/simple_form_for/registrations/new.html.erb +4 -4
  73. data/lib/generators/templates/simple_form_for/sessions/new.html.erb +4 -4
  74. data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +2 -2
  75. data/test/controllers/helpers_test.rb +31 -31
  76. data/test/controllers/internal_helpers_test.rb +6 -6
  77. data/test/controllers/sessions_controller_test.rb +18 -18
  78. data/test/controllers/url_helpers_test.rb +4 -4
  79. data/test/delegator_test.rb +1 -1
  80. data/test/devise_test.rb +3 -3
  81. data/test/failure_app_test.rb +21 -21
  82. data/test/generators/active_record_generator_test.rb +4 -4
  83. data/test/generators/devise_generator_test.rb +2 -2
  84. data/test/generators/mongoid_generator_test.rb +1 -1
  85. data/test/generators/views_generator_test.rb +30 -1
  86. data/test/helpers/devise_helper_test.rb +11 -11
  87. data/test/integration/authenticatable_test.rb +42 -42
  88. data/test/integration/confirmable_test.rb +46 -46
  89. data/test/integration/database_authenticatable_test.rb +16 -16
  90. data/test/integration/http_authenticatable_test.rb +11 -11
  91. data/test/integration/lockable_test.rb +37 -37
  92. data/test/integration/omniauthable_test.rb +3 -3
  93. data/test/integration/recoverable_test.rb +41 -41
  94. data/test/integration/registerable_test.rb +49 -49
  95. data/test/integration/rememberable_test.rb +13 -13
  96. data/test/integration/timeoutable_test.rb +7 -7
  97. data/test/integration/trackable_test.rb +2 -2
  98. data/test/mailers/confirmation_instructions_test.rb +4 -4
  99. data/test/mailers/reset_password_instructions_test.rb +3 -3
  100. data/test/mailers/unlock_instructions_test.rb +2 -2
  101. data/test/models/authenticatable_test.rb +3 -3
  102. data/test/models/confirmable_test.rb +31 -31
  103. data/test/models/database_authenticatable_test.rb +27 -27
  104. data/test/models/lockable_test.rb +29 -29
  105. data/test/models/recoverable_test.rb +19 -19
  106. data/test/models/rememberable_test.rb +8 -8
  107. data/test/models/serializable_test.rb +8 -8
  108. data/test/models/timeoutable_test.rb +1 -1
  109. data/test/models/validatable_test.rb +11 -11
  110. data/test/omniauth/config_test.rb +3 -3
  111. data/test/omniauth/url_helpers_test.rb +3 -3
  112. data/test/parameter_sanitizer_test.rb +1 -1
  113. data/test/rails_app/app/controllers/admins_controller.rb +1 -1
  114. data/test/rails_app/app/controllers/application_controller.rb +2 -2
  115. data/test/rails_app/app/controllers/home_controller.rb +1 -1
  116. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +2 -2
  117. data/test/rails_app/app/controllers/users_controller.rb +5 -5
  118. data/test/rails_app/app/mailers/users/mailer.rb +4 -4
  119. data/test/rails_app/app/mongoid/admin.rb +11 -11
  120. data/test/rails_app/app/mongoid/shim.rb +2 -2
  121. data/test/rails_app/app/mongoid/user.rb +19 -19
  122. data/test/rails_app/app/views/admins/sessions/new.html.erb +1 -1
  123. data/test/rails_app/app/views/layouts/application.html.erb +1 -1
  124. data/test/rails_app/config/application.rb +2 -2
  125. data/test/rails_app/config/initializers/devise.rb +3 -3
  126. data/test/rails_app/config/initializers/secret_token.rb +1 -1
  127. data/test/rails_app/config/routes.rb +43 -43
  128. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +7 -7
  129. data/test/rails_app/lib/shared_admin.rb +4 -4
  130. data/test/routes_test.rb +59 -59
  131. data/test/support/helpers.rb +4 -4
  132. data/test/support/integration.rb +12 -12
  133. data/test/test_helpers_test.rb +3 -3
  134. data/test/test_models.rb +5 -5
  135. 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, :allow_forgery_protection => true do
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, :allow_forgery_protection => true do
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, :authenticity_token => "oops", :user =>
51
- { email: "jose.valim@gmail.com", password: "123456", :remember_me => "1" }
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 :remember_me => true
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, :rememberable_options => { :domain => "omg.somewhere.com" } do
67
- sign_in_as_user :remember_me => true
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, :rememberable_options => { :key => "v1lat_token" } do
74
- sign_in_as_user :remember_me => true
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 :remember_me => true
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, :extend_remember_period => true, :remember_for => 1.year do
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 :remember_me => true
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, :remember_for => 0 do
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", :email => user.email, :password => "123456"
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, :timeout_in => 8.minutes do
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, :devise => {
149
- :failure => { :user => { :timeout => 'Session expired!' } }
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, :devise => {
162
- :failure => { :user => { :timeout => 'Session expired!' } }
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 :remember_me => true
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, :allow_unconfirmed_access_for => 0.days do
67
- user = create_user(:confirm => false)
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, :devise => { :mailer => { :confirmation_instructions => { :subject => 'Account Confirmation' } } } do
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, :devise => { :mailer => { :confirmation_instructions => { :user_subject => 'User Account Confirmation' } } } do
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, :scoped_views => true do
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, :mailer_sender => proc { "another@example.com" } do
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, :devise => { :mailer => { :reset_password_instructions => { :subject => 'Reset instructions' } } } do
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, :devise => { :mailer => { :reset_password_instructions => { :user_subject => 'User Reset Instructions' } } } do
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, :mailer_sender => proc { "another@example.com" } do
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, :devise => { :mailer => { :unlock_instructions => { :subject => 'Yo unlock instructions' } } } do
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, :devise => { :mailer => { :unlock_instructions => { :user_subject => 'User Unlock Instructions' } } } do
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!(: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)
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 :email => "mynewuser@example.com"
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(:validate => false)
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(:email => user.email)
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(:email => "invalid@example.com")
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(:email => "invalid@example.com")
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(:email => user.email)
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, :allow_unconfirmed_access_for => 1.day do
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, :allow_unconfirmed_access_for => 5.days do
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, :authentication_keys => [:username, :email] do
249
+ swap Devise, authentication_keys: [:username, :email] do
250
250
  user = create_user
251
- confirm_user = User.send_confirmation_instructions(:email => user.email, :username => user.username)
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, :confirmation_keys => [:username, :email] do
257
+ swap Devise, confirmation_keys: [:username, :email] do
258
258
  user = create_user
259
- confirm_user = User.send_confirmation_instructions(:email => user.email)
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, :confirm_within => 3.days do
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, :confirm_within => 3.days do
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(:email => 'new_test@example.com')
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(:email => 'new_test@example.com')
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(:email => 'new_test@example.com')
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(:email => 'old_test@example.com')
354
+ assert admin.update_attributes(email: 'old_test@example.com')
355
355
  token = admin.confirmation_token
356
- assert admin.update_attributes(:email => 'new_test@example.com')
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(:email => 'new_test@example.com')
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(:password => 'newpass', :password_confirmation => 'newpass')
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(:validate => false)
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(:email => 'new_test@example.com')
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(:email => 'new_test@example.com')
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(:email => 'new_test@example.com')
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(:email => 'new_test@example.com')
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(:email => 'new_test@example.com')
415
- confirmation_admin = Admin.send_confirmation_instructions(:email => admin.unconfirmed_email)
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(:email => "invalid@email.com")
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(:email => "invalid@email.com")
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(:email => "new_test@email.com")
434
+ admin = Admin.find_by_unconfirmed_email_with_errors(email: "new_test@email.com")
435
435
  assert admin.persisted?
436
436
  end
437
437