devise 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of devise might be problematic. Click here for more details.

Files changed (187) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +18 -3
  3. data/CHANGELOG.md +82 -9
  4. data/CONTRIBUTING.md +2 -2
  5. data/Gemfile +7 -9
  6. data/Gemfile.lock +102 -96
  7. data/MIT-LICENSE +1 -1
  8. data/README.md +94 -42
  9. data/Rakefile +1 -1
  10. data/app/controllers/devise/confirmations_controller.rb +5 -3
  11. data/app/controllers/devise/omniauth_callbacks_controller.rb +2 -2
  12. data/app/controllers/devise/passwords_controller.rb +5 -3
  13. data/app/controllers/devise/registrations_controller.rb +26 -10
  14. data/app/controllers/devise/sessions_controller.rb +39 -14
  15. data/app/controllers/devise/unlocks_controller.rb +4 -2
  16. data/app/controllers/devise_controller.rb +6 -6
  17. data/app/helpers/devise_helper.rb +2 -2
  18. data/app/views/devise/confirmations/new.html.erb +2 -2
  19. data/app/views/devise/mailer/confirmation_instructions.html.erb +1 -1
  20. data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
  21. data/app/views/devise/mailer/unlock_instructions.html.erb +1 -1
  22. data/app/views/devise/passwords/edit.html.erb +3 -3
  23. data/app/views/devise/passwords/new.html.erb +2 -2
  24. data/app/views/devise/registrations/edit.html.erb +6 -6
  25. data/app/views/devise/registrations/new.html.erb +5 -5
  26. data/app/views/devise/sessions/new.html.erb +5 -5
  27. data/app/views/devise/shared/_links.erb +1 -1
  28. data/app/views/devise/unlocks/new.html.erb +2 -2
  29. data/config/locales/en.yml +17 -16
  30. data/devise.gemspec +2 -2
  31. data/gemfiles/{Gemfile.rails-3.2.x → Gemfile.rails-3.2-stable} +8 -10
  32. data/gemfiles/Gemfile.rails-3.2-stable.lock +166 -0
  33. data/gemfiles/Gemfile.rails-4.0-stable +29 -0
  34. data/gemfiles/Gemfile.rails-4.0-stable.lock +162 -0
  35. data/gemfiles/Gemfile.rails-head +32 -0
  36. data/gemfiles/Gemfile.rails-head.lock +190 -0
  37. data/lib/devise/controllers/helpers.rb +84 -29
  38. data/lib/devise/controllers/rememberable.rb +3 -3
  39. data/lib/devise/controllers/scoped_views.rb +1 -1
  40. data/lib/devise/controllers/sign_in_out.rb +9 -10
  41. data/lib/devise/controllers/store_location.rb +56 -0
  42. data/lib/devise/controllers/url_helpers.rb +3 -1
  43. data/lib/devise/failure_app.rb +12 -10
  44. data/lib/devise/hooks/activatable.rb +5 -6
  45. data/lib/devise/hooks/csrf_cleaner.rb +3 -1
  46. data/lib/devise/hooks/lockable.rb +1 -1
  47. data/lib/devise/hooks/proxy.rb +2 -2
  48. data/lib/devise/hooks/rememberable.rb +2 -2
  49. data/lib/devise/hooks/timeoutable.rb +10 -3
  50. data/lib/devise/hooks/trackable.rb +1 -1
  51. data/lib/devise/mailers/helpers.rb +8 -8
  52. data/lib/devise/mapping.rb +4 -1
  53. data/lib/devise/models/authenticatable.rb +5 -5
  54. data/lib/devise/models/confirmable.rb +14 -14
  55. data/lib/devise/models/database_authenticatable.rb +18 -5
  56. data/lib/devise/models/lockable.rb +14 -11
  57. data/lib/devise/models/omniauthable.rb +1 -1
  58. data/lib/devise/models/recoverable.rb +23 -7
  59. data/lib/devise/models/rememberable.rb +6 -6
  60. data/lib/devise/models/timeoutable.rb +2 -2
  61. data/lib/devise/models/trackable.rb +5 -2
  62. data/lib/devise/models/validatable.rb +6 -6
  63. data/lib/devise/modules.rb +10 -10
  64. data/lib/devise/omniauth/url_helpers.rb +2 -2
  65. data/lib/devise/orm/active_record.rb +1 -1
  66. data/lib/devise/orm/mongoid.rb +1 -1
  67. data/lib/devise/rails/routes.rb +107 -78
  68. data/lib/devise/rails.rb +7 -1
  69. data/lib/devise/strategies/authenticatable.rb +11 -4
  70. data/lib/devise/strategies/base.rb +1 -1
  71. data/lib/devise/strategies/database_authenticatable.rb +7 -4
  72. data/lib/devise/test_helpers.rb +2 -2
  73. data/lib/devise/time_inflector.rb +2 -2
  74. data/lib/devise/version.rb +1 -1
  75. data/lib/devise.rb +15 -10
  76. data/lib/generators/active_record/devise_generator.rb +27 -10
  77. data/lib/generators/active_record/templates/migration.rb +4 -4
  78. data/lib/generators/active_record/templates/migration_existing.rb +4 -4
  79. data/lib/generators/devise/devise_generator.rb +5 -3
  80. data/lib/generators/devise/install_generator.rb +5 -0
  81. data/lib/generators/devise/views_generator.rb +31 -18
  82. data/lib/generators/mongoid/devise_generator.rb +20 -19
  83. data/lib/generators/templates/README +4 -4
  84. data/lib/generators/templates/devise.rb +20 -11
  85. data/lib/generators/templates/markerb/confirmation_instructions.markerb +1 -1
  86. data/lib/generators/templates/markerb/reset_password_instructions.markerb +1 -1
  87. data/lib/generators/templates/markerb/unlock_instructions.markerb +1 -1
  88. data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +2 -2
  89. data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +4 -4
  90. data/lib/generators/templates/simple_form_for/passwords/new.html.erb +2 -2
  91. data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +6 -6
  92. data/lib/generators/templates/simple_form_for/registrations/new.html.erb +4 -4
  93. data/lib/generators/templates/simple_form_for/sessions/new.html.erb +4 -4
  94. data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +2 -2
  95. data/script/cached-bundle +49 -0
  96. data/script/s3-put +71 -0
  97. data/test/controllers/custom_registrations_controller_test.rb +35 -0
  98. data/test/controllers/helpers_test.rb +89 -31
  99. data/test/controllers/internal_helpers_test.rb +11 -8
  100. data/test/controllers/passwords_controller_test.rb +1 -1
  101. data/test/controllers/sessions_controller_test.rb +29 -25
  102. data/test/controllers/url_helpers_test.rb +4 -4
  103. data/test/delegator_test.rb +1 -1
  104. data/test/devise_test.rb +21 -8
  105. data/test/failure_app_test.rb +61 -25
  106. data/test/generators/active_record_generator_test.rb +10 -4
  107. data/test/generators/devise_generator_test.rb +2 -2
  108. data/test/generators/mongoid_generator_test.rb +3 -3
  109. data/test/generators/views_generator_test.rb +30 -1
  110. data/test/helpers/devise_helper_test.rb +14 -13
  111. data/test/integration/authenticatable_test.rb +61 -45
  112. data/test/integration/confirmable_test.rb +95 -55
  113. data/test/integration/database_authenticatable_test.rb +16 -16
  114. data/test/integration/http_authenticatable_test.rb +12 -12
  115. data/test/integration/lockable_test.rb +43 -43
  116. data/test/integration/omniauthable_test.rb +3 -3
  117. data/test/integration/recoverable_test.rb +53 -53
  118. data/test/integration/registerable_test.rb +90 -80
  119. data/test/integration/rememberable_test.rb +15 -15
  120. data/test/integration/timeoutable_test.rb +27 -16
  121. data/test/integration/trackable_test.rb +4 -4
  122. data/test/mailers/confirmation_instructions_test.rb +7 -7
  123. data/test/mailers/reset_password_instructions_test.rb +6 -6
  124. data/test/mailers/unlock_instructions_test.rb +5 -5
  125. data/test/mapping_test.rb +3 -3
  126. data/test/models/authenticatable_test.rb +3 -3
  127. data/test/models/confirmable_test.rb +32 -32
  128. data/test/models/database_authenticatable_test.rb +32 -27
  129. data/test/models/lockable_test.rb +57 -33
  130. data/test/models/recoverable_test.rb +34 -22
  131. data/test/models/rememberable_test.rb +29 -14
  132. data/test/models/serializable_test.rb +8 -8
  133. data/test/models/timeoutable_test.rb +1 -1
  134. data/test/models/trackable_test.rb +28 -0
  135. data/test/models/validatable_test.rb +13 -13
  136. data/test/omniauth/config_test.rb +4 -4
  137. data/test/omniauth/url_helpers_test.rb +3 -3
  138. data/test/orm/mongoid.rb +1 -1
  139. data/test/parameter_sanitizer_test.rb +1 -1
  140. data/test/rails_app/app/active_record/shim.rb +1 -1
  141. data/test/rails_app/app/active_record/user_on_engine.rb +7 -0
  142. data/test/rails_app/app/active_record/user_on_main_app.rb +7 -0
  143. data/test/rails_app/app/controllers/admins/sessions_controller.rb +1 -1
  144. data/test/rails_app/app/controllers/admins_controller.rb +1 -1
  145. data/test/rails_app/app/controllers/application_controller.rb +5 -2
  146. data/test/rails_app/app/controllers/application_with_fake_engine.rb +30 -0
  147. data/test/rails_app/app/controllers/custom/registrations_controller.rb +21 -0
  148. data/test/rails_app/app/controllers/home_controller.rb +1 -1
  149. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +1 -1
  150. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +1 -1
  151. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +4 -4
  152. data/test/rails_app/app/controllers/users_controller.rb +6 -6
  153. data/test/rails_app/app/mailers/users/mailer.rb +4 -4
  154. data/test/rails_app/app/mongoid/admin.rb +11 -11
  155. data/test/rails_app/app/mongoid/shim.rb +2 -2
  156. data/test/rails_app/app/mongoid/user.rb +19 -19
  157. data/test/rails_app/app/mongoid/user_on_engine.rb +39 -0
  158. data/test/rails_app/app/mongoid/user_on_main_app.rb +39 -0
  159. data/test/rails_app/app/views/admins/sessions/new.html.erb +1 -1
  160. data/test/rails_app/app/views/home/admin_dashboard.html.erb +1 -1
  161. data/test/rails_app/app/views/home/index.html.erb +1 -1
  162. data/test/rails_app/app/views/home/join.html.erb +1 -1
  163. data/test/rails_app/app/views/home/user_dashboard.html.erb +1 -1
  164. data/test/rails_app/app/views/layouts/application.html.erb +1 -1
  165. data/test/rails_app/config/application.rb +2 -2
  166. data/test/rails_app/config/boot.rb +7 -1
  167. data/test/rails_app/config/environments/development.rb +0 -4
  168. data/test/rails_app/config/environments/production.rb +0 -4
  169. data/test/rails_app/config/initializers/devise.rb +7 -5
  170. data/test/rails_app/config/initializers/secret_token.rb +1 -1
  171. data/test/rails_app/config/routes.rb +60 -42
  172. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +7 -7
  173. data/test/rails_app/db/schema.rb +21 -17
  174. data/test/rails_app/lib/shared_admin.rb +4 -4
  175. data/test/rails_app/lib/shared_user.rb +1 -1
  176. data/test/rails_app/lib/shared_user_without_omniauth.rb +13 -0
  177. data/test/routes_test.rb +72 -58
  178. data/test/support/action_controller/record_identifier.rb +10 -0
  179. data/test/support/assertions.rb +2 -3
  180. data/test/support/helpers.rb +4 -4
  181. data/test/support/integration.rb +14 -14
  182. data/test/support/mongoid.yml +6 -0
  183. data/test/test_helper.rb +2 -7
  184. data/test/test_helpers_test.rb +25 -35
  185. data/test/test_models.rb +12 -5
  186. metadata +53 -38
  187. data/gemfiles/Gemfile.rails-3.2.x.lock +0 -159
@@ -3,18 +3,18 @@ require 'test_helper'
3
3
  class LockTest < ActionDispatch::IntegrationTest
4
4
 
5
5
  def visit_user_unlock_with_token(unlock_token)
6
- visit user_unlock_path(:unlock_token => unlock_token)
6
+ visit user_unlock_path(unlock_token: unlock_token)
7
7
  end
8
8
 
9
9
  def send_unlock_request
10
- user = create_user(:locked => true)
10
+ user = create_user(locked: true)
11
11
  ActionMailer::Base.deliveries.clear
12
12
 
13
13
  visit new_user_session_path
14
14
  click_link "Didn't receive unlock instructions?"
15
15
 
16
16
  Devise.stubs(:friendly_token).returns("abcdef")
17
- fill_in 'email', :with => user.email
17
+ fill_in 'email', with: user.email
18
18
  click_button 'Resend unlock instructions'
19
19
  end
20
20
 
@@ -22,7 +22,7 @@ class LockTest < ActionDispatch::IntegrationTest
22
22
  send_unlock_request
23
23
 
24
24
  assert_template 'sessions/new'
25
- assert_contain 'You will receive an email with instructions about how to unlock your account in a few minutes'
25
+ assert_contain 'You will receive an email with instructions for how to unlock your account in a few minutes'
26
26
 
27
27
  mail = ActionMailer::Base.deliveries.last
28
28
  assert_equal 1, ActionMailer::Base.deliveries.size
@@ -39,13 +39,13 @@ class LockTest < ActionDispatch::IntegrationTest
39
39
  end
40
40
 
41
41
  test 'unlocked user should not be able to request a unlock token' do
42
- user = create_user(:locked => false)
42
+ user = create_user(locked: false)
43
43
  ActionMailer::Base.deliveries.clear
44
44
 
45
45
  visit new_user_session_path
46
46
  click_link "Didn't receive unlock instructions?"
47
47
 
48
- fill_in 'email', :with => user.email
48
+ fill_in 'email', with: user.email
49
49
  click_button 'Resend unlock instructions'
50
50
 
51
51
  assert_template 'unlocks/new'
@@ -89,60 +89,60 @@ class LockTest < ActionDispatch::IntegrationTest
89
89
  end
90
90
 
91
91
  test "user should not send a new e-mail if already locked" do
92
- user = create_user(:locked => true)
92
+ user = create_user(locked: true)
93
93
  user.failed_attempts = User.maximum_attempts + 1
94
94
  user.save!
95
95
 
96
96
  ActionMailer::Base.deliveries.clear
97
97
 
98
- sign_in_as_user(:password => "invalid")
98
+ sign_in_as_user(password: "invalid")
99
99
  assert_contain 'Your account is locked.'
100
100
  assert ActionMailer::Base.deliveries.empty?
101
101
  end
102
102
 
103
103
  test 'error message is configurable by resource name' do
104
- store_translations :en, :devise => {
105
- :failure => {:user => {:locked => "You are locked!"}}
104
+ store_translations :en, devise: {
105
+ failure: {user: {locked: "You are locked!"}}
106
106
  } do
107
107
 
108
- user = create_user(:locked => true)
108
+ user = create_user(locked: true)
109
109
  user.failed_attempts = User.maximum_attempts + 1
110
110
  user.save!
111
111
 
112
- sign_in_as_user(:password => "invalid")
112
+ sign_in_as_user(password: "invalid")
113
113
  assert_contain "You are locked!"
114
114
  end
115
115
  end
116
116
 
117
117
  test "user should not be able to sign in when locked" do
118
- store_translations :en, :devise => {
119
- :failure => {:user => {:locked => "You are locked!"}}
118
+ store_translations :en, devise: {
119
+ failure: {user: {locked: "You are locked!"}}
120
120
  } do
121
121
 
122
- user = create_user(:locked => true)
122
+ user = create_user(locked: true)
123
123
  user.failed_attempts = User.maximum_attempts + 1
124
124
  user.save!
125
125
 
126
- sign_in_as_user(:password => "123456")
126
+ sign_in_as_user(password: "123456")
127
127
  assert_contain "You are locked!"
128
128
  end
129
129
  end
130
130
 
131
131
  test 'user should be able to request a new unlock token via XML request' do
132
- user = create_user(:locked => true)
132
+ user = create_user(locked: true)
133
133
  ActionMailer::Base.deliveries.clear
134
134
 
135
- post user_unlock_path(:format => 'xml'), :user => {:email => user.email}
135
+ post user_unlock_path(format: 'xml'), user: {email: user.email}
136
136
  assert_response :success
137
137
  assert_equal response.body, {}.to_xml
138
138
  assert_equal 1, ActionMailer::Base.deliveries.size
139
139
  end
140
140
 
141
141
  test 'unlocked user should not be able to request a unlock token via XML request' do
142
- user = create_user(:locked => false)
142
+ user = create_user(locked: false)
143
143
  ActionMailer::Base.deliveries.clear
144
144
 
145
- post user_unlock_path(:format => 'xml'), :user => {:email => user.email}
145
+ post user_unlock_path(format: 'xml'), user: {email: user.email}
146
146
  assert_response :unprocessable_entity
147
147
  assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
148
148
  assert_equal 0, ActionMailer::Base.deliveries.size
@@ -152,84 +152,84 @@ class LockTest < ActionDispatch::IntegrationTest
152
152
  user = create_user()
153
153
  raw = user.lock_access!
154
154
  assert user.access_locked?
155
- get user_unlock_path(:format => 'xml', :unlock_token => raw)
155
+ get user_unlock_path(format: 'xml', unlock_token: raw)
156
156
  assert_response :success
157
157
  assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>)
158
158
  end
159
159
 
160
160
 
161
161
  test 'user with invalid unlock token should not be able to unlock the account via XML request' do
162
- get user_unlock_path(:format => 'xml', :unlock_token => 'invalid_token')
162
+ get user_unlock_path(format: 'xml', unlock_token: 'invalid_token')
163
163
  assert_response :unprocessable_entity
164
164
  assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
165
165
  end
166
166
 
167
167
  test "when using json to ask a unlock request, should not return the user" do
168
- user = create_user(:locked => true)
169
- post user_unlock_path(:format => "json", :user => {:email => user.email})
168
+ user = create_user(locked: true)
169
+ post user_unlock_path(format: "json", user: {email: user.email})
170
170
  assert_response :success
171
171
  assert_equal response.body, {}.to_json
172
172
  end
173
173
 
174
174
  test "in paranoid mode, when trying to unlock an user that exists it should not say that it exists if it is locked" do
175
- swap Devise, :paranoid => true do
176
- user = create_user(:locked => true)
175
+ swap Devise, paranoid: true do
176
+ user = create_user(locked: true)
177
177
 
178
178
  visit new_user_session_path
179
179
  click_link "Didn't receive unlock instructions?"
180
180
 
181
- fill_in 'email', :with => user.email
181
+ fill_in 'email', with: user.email
182
182
  click_button 'Resend unlock instructions'
183
183
 
184
184
  assert_current_url "/users/sign_in"
185
- assert_contain "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes."
185
+ assert_contain "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
186
186
  end
187
187
  end
188
188
 
189
189
  test "in paranoid mode, when trying to unlock an user that exists it should not say that it exists if it is not locked" do
190
- swap Devise, :paranoid => true do
191
- user = create_user(:locked => false)
190
+ swap Devise, paranoid: true do
191
+ user = create_user(locked: false)
192
192
 
193
193
  visit new_user_session_path
194
194
  click_link "Didn't receive unlock instructions?"
195
195
 
196
- fill_in 'email', :with => user.email
196
+ fill_in 'email', with: user.email
197
197
  click_button 'Resend unlock instructions'
198
198
 
199
199
  assert_current_url "/users/sign_in"
200
- assert_contain "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes."
200
+ assert_contain "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
201
201
  end
202
202
  end
203
203
 
204
204
  test "in paranoid mode, when trying to unlock an user that does not exists it should not say that it does not exists" do
205
- swap Devise, :paranoid => true do
205
+ swap Devise, paranoid: true do
206
206
  visit new_user_session_path
207
207
  click_link "Didn't receive unlock instructions?"
208
208
 
209
- fill_in 'email', :with => "arandomemail@hotmail.com"
209
+ fill_in 'email', with: "arandomemail@hotmail.com"
210
210
  click_button 'Resend unlock instructions'
211
211
 
212
212
  assert_not_contain "1 error prohibited this user from being saved:"
213
213
  assert_not_contain "Email not found"
214
214
  assert_current_url "/users/sign_in"
215
215
 
216
- assert_contain "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes."
216
+ assert_contain "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
217
217
 
218
218
  end
219
219
  end
220
220
 
221
221
  test "in paranoid mode, when locking a user that exists it should not say that the user was locked" do
222
- swap Devise, :paranoid => true, :maximum_attempts => 1 do
223
- user = create_user(:locked => false)
222
+ swap Devise, paranoid: true, maximum_attempts: 1 do
223
+ user = create_user(locked: false)
224
224
 
225
225
  visit new_user_session_path
226
- fill_in 'email', :with => user.email
227
- fill_in 'password', :with => "abadpassword"
228
- click_button 'Sign in'
226
+ fill_in 'email', with: user.email
227
+ fill_in 'password', with: "abadpassword"
228
+ click_button 'Log in'
229
229
 
230
- fill_in 'email', :with => user.email
231
- fill_in 'password', :with => "abadpassword"
232
- click_button 'Sign in'
230
+ fill_in 'email', with: user.email
231
+ fill_in 'password', with: "abadpassword"
232
+ click_button 'Log in'
233
233
 
234
234
  assert_current_url "/users/sign_in"
235
235
  assert_not_contain "locked"
@@ -61,8 +61,8 @@ class OmniauthableIntegrationTest < ActionDispatch::IntegrationTest
61
61
 
62
62
  assert_difference "User.count" do
63
63
  visit "/users/sign_up"
64
- fill_in "Password", :with => "12345678"
65
- fill_in "Password confirmation", :with => "12345678"
64
+ fill_in "Password", with: "12345678"
65
+ fill_in "Password confirmation", with: "12345678"
66
66
  click_button "Sign up"
67
67
  end
68
68
 
@@ -111,7 +111,7 @@ class OmniauthableIntegrationTest < ActionDispatch::IntegrationTest
111
111
  test "generates a proper link when SCRIPT_NAME is set" do
112
112
  header 'SCRIPT_NAME', '/q'
113
113
  visit "/users/sign_in"
114
- assert_select "a", :href => "/q/users/auth/facebook"
114
+ assert_select "a", href: "/q/users/auth/facebook"
115
115
  end
116
116
 
117
117
  test "handles callback error parameter according to the specification" do
@@ -12,7 +12,7 @@ class PasswordTest < ActionDispatch::IntegrationTest
12
12
  assert_response :success
13
13
  assert_not warden.authenticated?(:user)
14
14
 
15
- fill_in 'email', :with => 'user@test.com'
15
+ fill_in 'email', with: 'user@test.com'
16
16
  yield if block_given?
17
17
 
18
18
  Devise.stubs(:friendly_token).returns("abcdef")
@@ -21,33 +21,33 @@ class PasswordTest < ActionDispatch::IntegrationTest
21
21
 
22
22
  def reset_password(options={}, &block)
23
23
  unless options[:visit] == false
24
- visit edit_user_password_path(:reset_password_token => options[:reset_password_token] || "abcdef")
24
+ visit edit_user_password_path(reset_password_token: options[:reset_password_token] || "abcdef")
25
25
  assert_response :success
26
26
  end
27
27
 
28
- fill_in 'New password', :with => '987654321'
29
- fill_in 'Confirm new password', :with => '987654321'
28
+ fill_in 'New password', with: '987654321'
29
+ fill_in 'Confirm new password', with: '987654321'
30
30
  yield if block_given?
31
31
  click_button 'Change my password'
32
32
  end
33
33
 
34
34
  test 'reset password with email of different case should succeed when email is in the list of case insensitive keys' do
35
- create_user(:email => 'Foo@Bar.com')
35
+ create_user(email: 'Foo@Bar.com')
36
36
 
37
37
  request_forgot_password do
38
- fill_in 'email', :with => 'foo@bar.com'
38
+ fill_in 'email', with: 'foo@bar.com'
39
39
  end
40
40
 
41
41
  assert_current_url '/users/sign_in'
42
- assert_contain 'You will receive an email with instructions about how to reset your password in a few minutes.'
42
+ assert_contain 'You will receive an email with instructions on how to reset your password in a few minutes.'
43
43
  end
44
44
 
45
45
  test 'reset password with email should send an email from a custom mailer' do
46
- create_user(:email => 'Foo@Bar.com')
46
+ create_user(email: 'Foo@Bar.com')
47
47
 
48
48
  User.any_instance.stubs(:devise_mailer).returns(Users::Mailer)
49
49
  request_forgot_password do
50
- fill_in 'email', :with => 'foo@bar.com'
50
+ fill_in 'email', with: 'foo@bar.com'
51
51
  end
52
52
 
53
53
  mail = ActionMailer::Base.deliveries.last
@@ -56,11 +56,11 @@ class PasswordTest < ActionDispatch::IntegrationTest
56
56
  end
57
57
 
58
58
  test 'reset password with email of different case should fail when email is NOT the list of case insensitive keys' do
59
- swap Devise, :case_insensitive_keys => [] do
60
- create_user(:email => 'Foo@Bar.com')
59
+ swap Devise, case_insensitive_keys: [] do
60
+ create_user(email: 'Foo@Bar.com')
61
61
 
62
62
  request_forgot_password do
63
- fill_in 'email', :with => 'foo@bar.com'
63
+ fill_in 'email', with: 'foo@bar.com'
64
64
  end
65
65
 
66
66
  assert_response :success
@@ -71,22 +71,22 @@ class PasswordTest < ActionDispatch::IntegrationTest
71
71
  end
72
72
 
73
73
  test 'reset password with email with extra whitespace should succeed when email is in the list of strip whitespace keys' do
74
- create_user(:email => 'foo@bar.com')
74
+ create_user(email: 'foo@bar.com')
75
75
 
76
76
  request_forgot_password do
77
- fill_in 'email', :with => ' foo@bar.com '
77
+ fill_in 'email', with: ' foo@bar.com '
78
78
  end
79
79
 
80
80
  assert_current_url '/users/sign_in'
81
- assert_contain 'You will receive an email with instructions about how to reset your password in a few minutes.'
81
+ assert_contain 'You will receive an email with instructions on how to reset your password in a few minutes.'
82
82
  end
83
83
 
84
84
  test 'reset password with email with extra whitespace should fail when email is NOT the list of strip whitespace keys' do
85
- swap Devise, :strip_whitespace_keys => [] do
86
- create_user(:email => 'foo@bar.com')
85
+ swap Devise, strip_whitespace_keys: [] do
86
+ create_user(email: 'foo@bar.com')
87
87
 
88
88
  request_forgot_password do
89
- fill_in 'email', :with => ' foo@bar.com '
89
+ fill_in 'email', with: ' foo@bar.com '
90
90
  end
91
91
 
92
92
  assert_response :success
@@ -111,12 +111,12 @@ class PasswordTest < ActionDispatch::IntegrationTest
111
111
  request_forgot_password
112
112
 
113
113
  assert_current_url '/users/sign_in'
114
- assert_contain 'You will receive an email with instructions about how to reset your password in a few minutes.'
114
+ assert_contain 'You will receive an email with instructions on how to reset your password in a few minutes.'
115
115
  end
116
116
 
117
117
  test 'not authenticated user with invalid email should receive an error message' do
118
118
  request_forgot_password do
119
- fill_in 'email', :with => 'invalid.test@test.com'
119
+ fill_in 'email', with: 'invalid.test@test.com'
120
120
  end
121
121
 
122
122
  assert_response :success
@@ -139,9 +139,9 @@ class PasswordTest < ActionDispatch::IntegrationTest
139
139
  assert_redirected_to "/users/sign_in"
140
140
  end
141
141
 
142
- test 'not authenticated user with invalid reset password token should not be able to change his password' do
142
+ test 'not authenticated user with invalid reset password token should not be able to change their password' do
143
143
  user = create_user
144
- reset_password :reset_password_token => 'invalid_reset_password'
144
+ reset_password reset_password_token: 'invalid_reset_password'
145
145
 
146
146
  assert_response :success
147
147
  assert_current_url '/users/password'
@@ -150,11 +150,11 @@ class PasswordTest < ActionDispatch::IntegrationTest
150
150
  assert_not user.reload.valid_password?('987654321')
151
151
  end
152
152
 
153
- test 'not authenticated user with valid reset password token but invalid password should not be able to change his password' do
153
+ test 'not authenticated user with valid reset password token but invalid password should not be able to change their password' do
154
154
  user = create_user
155
155
  request_forgot_password
156
156
  reset_password do
157
- fill_in 'Confirm new password', :with => 'other_password'
157
+ fill_in 'Confirm new password', with: 'other_password'
158
158
  end
159
159
 
160
160
  assert_response :success
@@ -165,27 +165,27 @@ class PasswordTest < ActionDispatch::IntegrationTest
165
165
  assert_not user.reload.valid_password?('987654321')
166
166
  end
167
167
 
168
- test 'not authenticated user with valid data should be able to change his password' do
168
+ test 'not authenticated user with valid data should be able to change their password' do
169
169
  user = create_user
170
170
  request_forgot_password
171
171
  reset_password
172
172
 
173
173
  assert_current_url '/'
174
- assert_contain 'Your password was changed successfully. You are now signed in.'
174
+ assert_contain 'Your password has been changed successfully. You are now signed in.'
175
175
  assert user.reload.valid_password?('987654321')
176
176
  end
177
177
 
178
- test 'after entering invalid data user should still be able to change his password' do
178
+ test 'after entering invalid data user should still be able to change their password' do
179
179
  user = create_user
180
180
  request_forgot_password
181
181
 
182
- reset_password { fill_in 'Confirm new password', :with => 'other_password' }
182
+ reset_password { fill_in 'Confirm new password', with: 'other_password' }
183
183
  assert_response :success
184
184
  assert_have_selector '#error_explanation'
185
185
  assert_not user.reload.valid_password?('987654321')
186
186
 
187
- reset_password :visit => false
188
- assert_contain 'Your password was changed successfully.'
187
+ reset_password visit: false
188
+ assert_contain 'Your password has been changed successfully.'
189
189
  assert user.reload.valid_password?('987654321')
190
190
  end
191
191
 
@@ -199,12 +199,12 @@ class PasswordTest < ActionDispatch::IntegrationTest
199
199
 
200
200
  test 'does not sign in user automatically after changing its password if it\'s locked and unlock strategy is :none or :time' do
201
201
  [:none, :time].each do |strategy|
202
- swap Devise, :unlock_strategy => strategy do
203
- user = create_user(:locked => true)
202
+ swap Devise, unlock_strategy: strategy do
203
+ user = create_user(locked: true)
204
204
  request_forgot_password
205
205
  reset_password
206
206
 
207
- assert_contain 'Your password was changed successfully.'
207
+ assert_contain 'Your password has been changed successfully.'
208
208
  assert_not_contain 'You are now signed in.'
209
209
  assert_equal new_user_session_path, @request.path
210
210
  assert !warden.authenticated?(:user)
@@ -213,24 +213,24 @@ class PasswordTest < ActionDispatch::IntegrationTest
213
213
  end
214
214
 
215
215
  test 'unlocks and signs in locked user automatically after changing it\'s password if unlock strategy is :email' do
216
- swap Devise, :unlock_strategy => :email do
217
- user = create_user(:locked => true)
216
+ swap Devise, unlock_strategy: :email do
217
+ user = create_user(locked: true)
218
218
  request_forgot_password
219
219
  reset_password
220
220
 
221
- assert_contain 'Your password was changed successfully.'
221
+ assert_contain 'Your password has been changed successfully.'
222
222
  assert !user.reload.access_locked?
223
223
  assert warden.authenticated?(:user)
224
224
  end
225
225
  end
226
226
 
227
227
  test 'unlocks and signs in locked user automatically after changing it\'s password if unlock strategy is :both' do
228
- swap Devise, :unlock_strategy => :both do
229
- user = create_user(:locked => true)
228
+ swap Devise, unlock_strategy: :both do
229
+ user = create_user(locked: true)
230
230
  request_forgot_password
231
231
  reset_password
232
232
 
233
- assert_contain 'Your password was changed successfully.'
233
+ assert_contain 'Your password has been changed successfully.'
234
234
  assert !user.reload.access_locked?
235
235
  assert warden.authenticated?(:user)
236
236
  end
@@ -238,22 +238,22 @@ class PasswordTest < ActionDispatch::IntegrationTest
238
238
 
239
239
  test 'reset password request with valid E-Mail in XML format should return valid response' do
240
240
  create_user
241
- post user_password_path(:format => 'xml'), :user => {:email => "user@test.com"}
241
+ post user_password_path(format: 'xml'), user: {email: "user@test.com"}
242
242
  assert_response :success
243
243
  assert_equal response.body, { }.to_xml
244
244
  end
245
245
 
246
246
  test 'reset password request with invalid E-Mail in XML format should return valid response' do
247
247
  create_user
248
- post user_password_path(:format => 'xml'), :user => {:email => "invalid.test@test.com"}
248
+ post user_password_path(format: 'xml'), user: {email: "invalid.test@test.com"}
249
249
  assert_response :unprocessable_entity
250
250
  assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
251
251
  end
252
252
 
253
253
  test 'reset password request with invalid E-Mail in XML format should return empty and valid response' do
254
- swap Devise, :paranoid => true do
254
+ swap Devise, paranoid: true do
255
255
  create_user
256
- post user_password_path(:format => 'xml'), :user => {:email => "invalid@test.com"}
256
+ post user_password_path(format: 'xml'), user: {email: "invalid@test.com"}
257
257
  assert_response :success
258
258
  assert_equal response.body, { }.to_xml
259
259
  end
@@ -262,8 +262,8 @@ class PasswordTest < ActionDispatch::IntegrationTest
262
262
  test 'change password with valid parameters in XML format should return valid response' do
263
263
  create_user
264
264
  request_forgot_password
265
- put user_password_path(:format => 'xml'), :user => {
266
- :reset_password_token => 'abcdef', :password => '987654321', :password_confirmation => '987654321'
265
+ put user_password_path(format: 'xml'), user: {
266
+ reset_password_token: 'abcdef', password: '987654321', password_confirmation: '987654321'
267
267
  }
268
268
  assert_response :success
269
269
  assert warden.authenticated?(:user)
@@ -272,7 +272,7 @@ class PasswordTest < ActionDispatch::IntegrationTest
272
272
  test 'change password with invalid token in XML format should return invalid response' do
273
273
  create_user
274
274
  request_forgot_password
275
- put user_password_path(:format => 'xml'), :user => {:reset_password_token => 'invalid.token', :password => '987654321', :password_confirmation => '987654321'}
275
+ put user_password_path(format: 'xml'), user: {reset_password_token: 'invalid.token', password: '987654321', password_confirmation: '987654321'}
276
276
  assert_response :unprocessable_entity
277
277
  assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
278
278
  end
@@ -280,24 +280,24 @@ class PasswordTest < ActionDispatch::IntegrationTest
280
280
  test 'change password with invalid new password in XML format should return invalid response' do
281
281
  user = create_user
282
282
  request_forgot_password
283
- put user_password_path(:format => 'xml'), :user => {:reset_password_token => user.reload.reset_password_token, :password => '', :password_confirmation => '987654321'}
283
+ put user_password_path(format: 'xml'), user: {reset_password_token: user.reload.reset_password_token, password: '', password_confirmation: '987654321'}
284
284
  assert_response :unprocessable_entity
285
285
  assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
286
286
  end
287
287
 
288
288
  test "when using json requests to ask a confirmable request, should not return the object" do
289
- user = create_user(:confirm => false)
289
+ user = create_user(confirm: false)
290
290
 
291
- post user_password_path(:format => :json), :user => { :email => user.email }
291
+ post user_password_path(format: :json), user: { email: user.email }
292
292
 
293
293
  assert_response :success
294
294
  assert_equal response.body, "{}"
295
295
  end
296
296
 
297
297
  test "when in paranoid mode and with an invalid e-mail, asking to reset a password should display a message that does not indicates that the e-mail does not exists in the database" do
298
- swap Devise, :paranoid => true do
298
+ swap Devise, paranoid: true do
299
299
  visit_new_password_path
300
- fill_in "email", :with => "arandomemail@test.com"
300
+ fill_in "email", with: "arandomemail@test.com"
301
301
  click_button 'Send me reset password instructions'
302
302
 
303
303
  assert_not_contain "1 error prohibited this user from being saved:"
@@ -308,10 +308,10 @@ class PasswordTest < ActionDispatch::IntegrationTest
308
308
  end
309
309
 
310
310
  test "when in paranoid mode and with a valid e-mail, asking to reset password should display a message that does not indicates that the email exists in the database and redirect to the failure route" do
311
- swap Devise, :paranoid => true do
311
+ swap Devise, paranoid: true do
312
312
  user = create_user
313
313
  visit_new_password_path
314
- fill_in 'email', :with => user.email
314
+ fill_in 'email', with: user.email
315
315
  click_button 'Send me reset password instructions'
316
316
 
317
317
  assert_contain "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."