devise 4.5.0 → 4.6.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


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

Files changed (195) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +30 -1
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +18 -0
  5. data/app/controllers/devise/passwords_controller.rb +1 -0
  6. data/app/controllers/devise/registrations_controller.rb +25 -7
  7. data/app/helpers/devise_helper.rb +10 -19
  8. data/app/views/devise/confirmations/new.html.erb +1 -1
  9. data/app/views/devise/passwords/edit.html.erb +1 -1
  10. data/app/views/devise/passwords/new.html.erb +1 -1
  11. data/app/views/devise/registrations/edit.html.erb +1 -1
  12. data/app/views/devise/registrations/new.html.erb +1 -1
  13. data/app/views/devise/sessions/new.html.erb +2 -2
  14. data/app/views/devise/shared/_error_messages.html.erb +15 -0
  15. data/app/views/devise/shared/_links.html.erb +7 -7
  16. data/app/views/devise/unlocks/new.html.erb +1 -1
  17. data/config/locales/en.yml +1 -0
  18. data/lib/devise.rb +4 -0
  19. data/lib/devise/controllers/helpers.rb +1 -1
  20. data/lib/devise/failure_app.rb +28 -3
  21. data/lib/devise/models/authenticatable.rb +7 -15
  22. data/lib/devise/models/confirmable.rb +4 -1
  23. data/lib/devise/models/database_authenticatable.rb +41 -6
  24. data/lib/devise/models/lockable.rb +2 -2
  25. data/lib/devise/models/registerable.rb +2 -0
  26. data/lib/devise/strategies/database_authenticatable.rb +3 -0
  27. data/lib/devise/test/controller_helpers.rb +1 -1
  28. data/lib/devise/version.rb +1 -1
  29. data/lib/generators/active_record/devise_generator.rb +4 -4
  30. data/lib/generators/devise/controllers_generator.rb +1 -1
  31. data/lib/generators/templates/devise.rb +12 -3
  32. data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +1 -1
  33. data/lib/generators/templates/simple_form_for/registrations/new.html.erb +1 -1
  34. metadata +5 -305
  35. data/.gitignore +0 -10
  36. data/.travis.yml +0 -69
  37. data/.yardopts +0 -9
  38. data/CODE_OF_CONDUCT.md +0 -22
  39. data/CONTRIBUTING.md +0 -79
  40. data/Gemfile +0 -39
  41. data/Gemfile.lock +0 -202
  42. data/ISSUE_TEMPLATE.md +0 -19
  43. data/Rakefile +0 -37
  44. data/bin/test +0 -13
  45. data/devise.gemspec +0 -28
  46. data/devise.png +0 -0
  47. data/gemfiles/Gemfile.rails-4.1-stable +0 -32
  48. data/gemfiles/Gemfile.rails-4.1-stable.lock +0 -171
  49. data/gemfiles/Gemfile.rails-4.2-stable +0 -32
  50. data/gemfiles/Gemfile.rails-4.2-stable.lock +0 -192
  51. data/gemfiles/Gemfile.rails-5.0-stable +0 -33
  52. data/gemfiles/Gemfile.rails-5.0-stable.lock +0 -192
  53. data/gemfiles/Gemfile.rails-5.2-rc1 +0 -26
  54. data/gemfiles/Gemfile.rails-5.2-rc1.lock +0 -201
  55. data/guides/bug_report_templates/integration_test.rb +0 -106
  56. data/test/controllers/custom_registrations_controller_test.rb +0 -42
  57. data/test/controllers/custom_strategy_test.rb +0 -66
  58. data/test/controllers/helper_methods_test.rb +0 -24
  59. data/test/controllers/helpers_test.rb +0 -318
  60. data/test/controllers/inherited_controller_i18n_messages_test.rb +0 -53
  61. data/test/controllers/internal_helpers_test.rb +0 -129
  62. data/test/controllers/load_hooks_controller_test.rb +0 -21
  63. data/test/controllers/passwords_controller_test.rb +0 -34
  64. data/test/controllers/sessions_controller_test.rb +0 -108
  65. data/test/controllers/url_helpers_test.rb +0 -67
  66. data/test/delegator_test.rb +0 -21
  67. data/test/devise_test.rb +0 -109
  68. data/test/failure_app_test.rb +0 -346
  69. data/test/generators/active_record_generator_test.rb +0 -130
  70. data/test/generators/controllers_generator_test.rb +0 -50
  71. data/test/generators/devise_generator_test.rb +0 -41
  72. data/test/generators/install_generator_test.rb +0 -26
  73. data/test/generators/mongoid_generator_test.rb +0 -25
  74. data/test/generators/views_generator_test.rb +0 -105
  75. data/test/helpers/devise_helper_test.rb +0 -51
  76. data/test/integration/authenticatable_test.rb +0 -706
  77. data/test/integration/confirmable_test.rb +0 -326
  78. data/test/integration/database_authenticatable_test.rb +0 -110
  79. data/test/integration/http_authenticatable_test.rb +0 -114
  80. data/test/integration/lockable_test.rb +0 -242
  81. data/test/integration/mounted_engine_test.rb +0 -38
  82. data/test/integration/omniauthable_test.rb +0 -148
  83. data/test/integration/recoverable_test.rb +0 -349
  84. data/test/integration/registerable_test.rb +0 -365
  85. data/test/integration/rememberable_test.rb +0 -219
  86. data/test/integration/timeoutable_test.rb +0 -186
  87. data/test/integration/trackable_test.rb +0 -99
  88. data/test/mailers/confirmation_instructions_test.rb +0 -117
  89. data/test/mailers/email_changed_test.rb +0 -132
  90. data/test/mailers/mailer_test.rb +0 -20
  91. data/test/mailers/reset_password_instructions_test.rb +0 -98
  92. data/test/mailers/unlock_instructions_test.rb +0 -93
  93. data/test/mapping_test.rb +0 -136
  94. data/test/models/authenticatable_test.rb +0 -25
  95. data/test/models/confirmable_test.rb +0 -549
  96. data/test/models/database_authenticatable_test.rb +0 -290
  97. data/test/models/lockable_test.rb +0 -352
  98. data/test/models/omniauthable_test.rb +0 -9
  99. data/test/models/recoverable_test.rb +0 -263
  100. data/test/models/registerable_test.rb +0 -9
  101. data/test/models/rememberable_test.rb +0 -184
  102. data/test/models/serializable_test.rb +0 -60
  103. data/test/models/timeoutable_test.rb +0 -53
  104. data/test/models/trackable_test.rb +0 -80
  105. data/test/models/validatable_test.rb +0 -121
  106. data/test/models_test.rb +0 -155
  107. data/test/omniauth/config_test.rb +0 -61
  108. data/test/omniauth/url_helpers_test.rb +0 -53
  109. data/test/orm/active_record.rb +0 -24
  110. data/test/orm/mongoid.rb +0 -15
  111. data/test/parameter_sanitizer_test.rb +0 -105
  112. data/test/rails_app/Rakefile +0 -6
  113. data/test/rails_app/app/active_record/admin.rb +0 -8
  114. data/test/rails_app/app/active_record/shim.rb +0 -4
  115. data/test/rails_app/app/active_record/user.rb +0 -20
  116. data/test/rails_app/app/active_record/user_on_engine.rb +0 -9
  117. data/test/rails_app/app/active_record/user_on_main_app.rb +0 -9
  118. data/test/rails_app/app/active_record/user_with_validations.rb +0 -12
  119. data/test/rails_app/app/active_record/user_without_email.rb +0 -10
  120. data/test/rails_app/app/controllers/admins/sessions_controller.rb +0 -8
  121. data/test/rails_app/app/controllers/admins_controller.rb +0 -8
  122. data/test/rails_app/app/controllers/application_controller.rb +0 -13
  123. data/test/rails_app/app/controllers/application_with_fake_engine.rb +0 -32
  124. data/test/rails_app/app/controllers/custom/registrations_controller.rb +0 -33
  125. data/test/rails_app/app/controllers/home_controller.rb +0 -31
  126. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +0 -4
  127. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +0 -4
  128. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +0 -16
  129. data/test/rails_app/app/controllers/users_controller.rb +0 -33
  130. data/test/rails_app/app/helpers/application_helper.rb +0 -5
  131. data/test/rails_app/app/mailers/users/from_proc_mailer.rb +0 -5
  132. data/test/rails_app/app/mailers/users/mailer.rb +0 -5
  133. data/test/rails_app/app/mailers/users/reply_to_mailer.rb +0 -6
  134. data/test/rails_app/app/mongoid/admin.rb +0 -31
  135. data/test/rails_app/app/mongoid/shim.rb +0 -25
  136. data/test/rails_app/app/mongoid/user.rb +0 -50
  137. data/test/rails_app/app/mongoid/user_on_engine.rb +0 -41
  138. data/test/rails_app/app/mongoid/user_on_main_app.rb +0 -41
  139. data/test/rails_app/app/mongoid/user_with_validations.rb +0 -37
  140. data/test/rails_app/app/mongoid/user_without_email.rb +0 -35
  141. data/test/rails_app/app/views/admins/index.html.erb +0 -1
  142. data/test/rails_app/app/views/admins/sessions/new.html.erb +0 -2
  143. data/test/rails_app/app/views/home/admin_dashboard.html.erb +0 -1
  144. data/test/rails_app/app/views/home/index.html.erb +0 -1
  145. data/test/rails_app/app/views/home/join.html.erb +0 -1
  146. data/test/rails_app/app/views/home/private.html.erb +0 -1
  147. data/test/rails_app/app/views/home/user_dashboard.html.erb +0 -1
  148. data/test/rails_app/app/views/layouts/application.html.erb +0 -24
  149. data/test/rails_app/app/views/users/edit_form.html.erb +0 -1
  150. data/test/rails_app/app/views/users/index.html.erb +0 -1
  151. data/test/rails_app/app/views/users/mailer/confirmation_instructions.erb +0 -1
  152. data/test/rails_app/app/views/users/sessions/new.html.erb +0 -1
  153. data/test/rails_app/bin/bundle +0 -3
  154. data/test/rails_app/bin/rails +0 -4
  155. data/test/rails_app/bin/rake +0 -4
  156. data/test/rails_app/config.ru +0 -4
  157. data/test/rails_app/config/application.rb +0 -48
  158. data/test/rails_app/config/boot.rb +0 -27
  159. data/test/rails_app/config/database.yml +0 -18
  160. data/test/rails_app/config/environment.rb +0 -7
  161. data/test/rails_app/config/environments/development.rb +0 -32
  162. data/test/rails_app/config/environments/production.rb +0 -88
  163. data/test/rails_app/config/environments/test.rb +0 -47
  164. data/test/rails_app/config/initializers/backtrace_silencers.rb +0 -9
  165. data/test/rails_app/config/initializers/devise.rb +0 -187
  166. data/test/rails_app/config/initializers/inflections.rb +0 -4
  167. data/test/rails_app/config/initializers/secret_token.rb +0 -5
  168. data/test/rails_app/config/initializers/session_store.rb +0 -3
  169. data/test/rails_app/config/routes.rb +0 -128
  170. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +0 -77
  171. data/test/rails_app/db/schema.rb +0 -57
  172. data/test/rails_app/lib/lazy_load_test_module.rb +0 -5
  173. data/test/rails_app/lib/shared_admin.rb +0 -23
  174. data/test/rails_app/lib/shared_user.rb +0 -32
  175. data/test/rails_app/lib/shared_user_without_email.rb +0 -28
  176. data/test/rails_app/lib/shared_user_without_omniauth.rb +0 -15
  177. data/test/rails_app/public/404.html +0 -26
  178. data/test/rails_app/public/422.html +0 -26
  179. data/test/rails_app/public/500.html +0 -26
  180. data/test/rails_app/public/favicon.ico +0 -0
  181. data/test/rails_test.rb +0 -11
  182. data/test/routes_test.rb +0 -281
  183. data/test/secret_key_finder_test.rb +0 -121
  184. data/test/support/action_controller/record_identifier.rb +0 -12
  185. data/test/support/assertions.rb +0 -30
  186. data/test/support/helpers.rb +0 -83
  187. data/test/support/http_method_compatibility.rb +0 -53
  188. data/test/support/integration.rb +0 -95
  189. data/test/support/locale/en.yml +0 -8
  190. data/test/support/mongoid.yml +0 -6
  191. data/test/support/webrat/integrations/rails.rb +0 -35
  192. data/test/test/controller_helpers_test.rb +0 -193
  193. data/test/test/integration_helpers_test.rb +0 -34
  194. data/test/test_helper.rb +0 -36
  195. data/test/test_models.rb +0 -35
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/500.html -->
21
- <div class="dialog">
22
- <h1>We're sorry, but something went wrong.</h1>
23
- <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
- </div>
25
- </body>
26
- </html>
File without changes
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class RailsTest < ActiveSupport::TestCase
6
- test 'correct initializer position' do
7
- initializer = Devise::Engine.initializers.detect { |i| i.name == 'devise.omniauth' }
8
- assert_equal :load_config_initializers, initializer.after
9
- assert_equal :build_middleware_stack, initializer.before
10
- end
11
- end
@@ -1,281 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- ExpectedRoutingError = MiniTest::Assertion
6
-
7
- class DefaultRoutingTest < ActionController::TestCase
8
- test 'map new user session' do
9
- assert_recognizes({controller: 'devise/sessions', action: 'new'}, {path: 'users/sign_in', method: :get})
10
- assert_named_route "/users/sign_in", :new_user_session_path
11
- end
12
-
13
- test 'map create user session' do
14
- assert_recognizes({controller: 'devise/sessions', action: 'create'}, {path: 'users/sign_in', method: :post})
15
- assert_named_route "/users/sign_in", :user_session_path
16
- end
17
-
18
- test 'map destroy user session' do
19
- assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: 'users/sign_out', method: :delete})
20
- assert_named_route "/users/sign_out", :destroy_user_session_path
21
- end
22
-
23
- test 'map new user confirmation' do
24
- assert_recognizes({controller: 'devise/confirmations', action: 'new'}, 'users/confirmation/new')
25
- assert_named_route "/users/confirmation/new", :new_user_confirmation_path
26
- end
27
-
28
- test 'map create user confirmation' do
29
- assert_recognizes({controller: 'devise/confirmations', action: 'create'}, {path: 'users/confirmation', method: :post})
30
- assert_named_route "/users/confirmation", :user_confirmation_path
31
- end
32
-
33
- test 'map show user confirmation' do
34
- assert_recognizes({controller: 'devise/confirmations', action: 'show'}, {path: 'users/confirmation', method: :get})
35
- end
36
-
37
- test 'map new user password' do
38
- assert_recognizes({controller: 'devise/passwords', action: 'new'}, 'users/password/new')
39
- assert_named_route "/users/password/new", :new_user_password_path
40
- end
41
-
42
- test 'map create user password' do
43
- assert_recognizes({controller: 'devise/passwords', action: 'create'}, {path: 'users/password', method: :post})
44
- assert_named_route "/users/password", :user_password_path
45
- end
46
-
47
- test 'map edit user password' do
48
- assert_recognizes({controller: 'devise/passwords', action: 'edit'}, 'users/password/edit')
49
- assert_named_route "/users/password/edit", :edit_user_password_path
50
- end
51
-
52
- test 'map update user password' do
53
- assert_recognizes({controller: 'devise/passwords', action: 'update'}, {path: 'users/password', method: :put})
54
- end
55
-
56
- test 'map new user unlock' do
57
- assert_recognizes({controller: 'devise/unlocks', action: 'new'}, 'users/unlock/new')
58
- assert_named_route "/users/unlock/new", :new_user_unlock_path
59
- end
60
-
61
- test 'map create user unlock' do
62
- assert_recognizes({controller: 'devise/unlocks', action: 'create'}, {path: 'users/unlock', method: :post})
63
- assert_named_route "/users/unlock", :user_unlock_path
64
- end
65
-
66
- test 'map show user unlock' do
67
- assert_recognizes({controller: 'devise/unlocks', action: 'show'}, {path: 'users/unlock', method: :get})
68
- end
69
-
70
- test 'map new user registration' do
71
- assert_recognizes({controller: 'devise/registrations', action: 'new'}, 'users/sign_up')
72
- assert_named_route "/users/sign_up", :new_user_registration_path
73
- end
74
-
75
- test 'map create user registration' do
76
- assert_recognizes({controller: 'devise/registrations', action: 'create'}, {path: 'users', method: :post})
77
- assert_named_route "/users", :user_registration_path
78
- end
79
-
80
- test 'map edit user registration' do
81
- assert_recognizes({controller: 'devise/registrations', action: 'edit'}, {path: 'users/edit', method: :get})
82
- assert_named_route "/users/edit", :edit_user_registration_path
83
- end
84
-
85
- test 'map update user registration' do
86
- assert_recognizes({controller: 'devise/registrations', action: 'update'}, {path: 'users', method: :put})
87
- end
88
-
89
- test 'map destroy user registration' do
90
- assert_recognizes({controller: 'devise/registrations', action: 'destroy'}, {path: 'users', method: :delete})
91
- end
92
-
93
- test 'map cancel user registration' do
94
- assert_recognizes({controller: 'devise/registrations', action: 'cancel'}, {path: 'users/cancel', method: :get})
95
- assert_named_route "/users/cancel", :cancel_user_registration_path
96
- end
97
-
98
- test 'map omniauth callbacks' do
99
- assert_recognizes({controller: 'users/omniauth_callbacks', action: 'facebook'}, {path: 'users/auth/facebook/callback', method: :get})
100
- assert_recognizes({controller: 'users/omniauth_callbacks', action: 'facebook'}, {path: 'users/auth/facebook/callback', method: :post})
101
- assert_named_route "/users/auth/facebook/callback", :user_facebook_omniauth_callback_path
102
-
103
- # named open_id
104
- assert_recognizes({controller: 'users/omniauth_callbacks', action: 'google'}, {path: 'users/auth/google/callback', method: :get})
105
- assert_recognizes({controller: 'users/omniauth_callbacks', action: 'google'}, {path: 'users/auth/google/callback', method: :post})
106
- assert_named_route "/users/auth/google/callback", :user_google_omniauth_callback_path
107
-
108
- assert_raise ExpectedRoutingError do
109
- assert_recognizes({controller: 'ysers/omniauth_callbacks', action: 'twitter'}, {path: 'users/auth/twitter/callback', method: :get})
110
- end
111
- end
112
-
113
- protected
114
-
115
- def assert_named_route(result, *args)
116
- assert_equal result, @routes.url_helpers.send(*args)
117
- end
118
- end
119
-
120
- class CustomizedRoutingTest < ActionController::TestCase
121
- test 'map admin with :path option' do
122
- assert_recognizes({controller: 'devise/registrations', action: 'new'}, {path: 'admin_area/sign_up', method: :get})
123
- end
124
-
125
- test 'map admin with :controllers option' do
126
- assert_recognizes({controller: 'admins/sessions', action: 'new'}, {path: 'admin_area/sign_in', method: :get})
127
- end
128
-
129
- test 'does not map admin password' do
130
- assert_raise ExpectedRoutingError do
131
- assert_recognizes({controller: 'devise/passwords', action: 'new'}, 'admin_area/password/new')
132
- end
133
- end
134
-
135
- test 'subdomain admin' do
136
- assert_recognizes({"host"=>"sub.example.com", controller: 'devise/sessions', action: 'new'}, {host: "sub.example.com", path: '/sub_admin/sign_in', method: :get})
137
- end
138
-
139
- test 'does only map reader password' do
140
- assert_raise ExpectedRoutingError do
141
- assert_recognizes({controller: 'devise/sessions', action: 'new'}, 'reader/sessions/new')
142
- end
143
- assert_recognizes({controller: 'devise/passwords', action: 'new'}, 'reader/password/new')
144
- end
145
-
146
- test 'map account with custom path name for session sign in' do
147
- assert_recognizes({controller: 'devise/sessions', action: 'new', locale: 'en'}, '/en/accounts/login')
148
- end
149
-
150
- test 'map account with custom path name for session sign out' do
151
- assert_recognizes({controller: 'devise/sessions', action: 'destroy', locale: 'en'}, {path: '/en/accounts/logout', method: :delete })
152
- end
153
-
154
- test 'map account with custom path name for password' do
155
- assert_recognizes({controller: 'devise/passwords', action: 'new', locale: 'en'}, '/en/accounts/secret/new')
156
- end
157
-
158
- test 'map account with custom path name for registration' do
159
- assert_recognizes({controller: 'devise/registrations', action: 'new', locale: 'en'}, '/en/accounts/management/register')
160
- end
161
-
162
- test 'map account with custom path name for edit registration' do
163
- assert_recognizes({controller: 'devise/registrations', action: 'edit', locale: 'en'}, '/en/accounts/management/edit/profile')
164
- end
165
-
166
- test 'map account with custom path name for cancel registration' do
167
- assert_recognizes({controller: 'devise/registrations', action: 'cancel', locale: 'en'}, '/en/accounts/management/giveup')
168
- end
169
-
170
- test 'map deletes with :sign_out_via option' do
171
- assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/deletes/sign_out', method: :delete})
172
- assert_raise ExpectedRoutingError do
173
- assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/deletes/sign_out', method: :get})
174
- end
175
- end
176
-
177
- test 'map posts with :sign_out_via option' do
178
- assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/posts/sign_out', method: :post})
179
- assert_raise ExpectedRoutingError do
180
- assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/posts/sign_out', method: :get})
181
- end
182
- end
183
-
184
- test 'map delete_or_posts with :sign_out_via option' do
185
- assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/delete_or_posts/sign_out', method: :post})
186
- assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/delete_or_posts/sign_out', method: :delete})
187
- assert_raise ExpectedRoutingError do
188
- assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/delete_or_posts/sign_out', method: :get})
189
- end
190
- end
191
-
192
- test 'map with constraints defined in hash' do
193
- assert_recognizes({controller: 'devise/registrations', action: 'new'}, {path: 'http://192.168.1.100/headquarters/sign_up', method: :get})
194
- assert_raise ExpectedRoutingError do
195
- assert_recognizes({controller: 'devise/registrations', action: 'new'}, {path: 'http://10.0.0.100/headquarters/sign_up', method: :get})
196
- end
197
- end
198
-
199
- test 'map with constraints defined in block' do
200
- assert_recognizes({controller: 'devise/registrations', action: 'new'}, {path: 'http://192.168.1.100/homebase/sign_up', method: :get})
201
- assert_raise ExpectedRoutingError do
202
- assert_recognizes({controller: 'devise/registrations', action: 'new'}, {path: 'http://10.0.0.100//homebase/sign_up', method: :get})
203
- end
204
- end
205
-
206
- test 'map with format false for sessions' do
207
- expected_params = {controller: 'devise/sessions', action: 'new'}
208
- expected_params[:format] = false if Devise::Test.rails5?
209
-
210
- assert_recognizes(expected_params, {path: '/htmlonly_admin/sign_in', method: :get})
211
- assert_raise ExpectedRoutingError do
212
- assert_recognizes(expected_params, {path: '/htmlonly_admin/sign_in.xml', method: :get})
213
- end
214
- end
215
-
216
- test 'map with format false for passwords' do
217
- expected_params = {controller: 'devise/passwords', action: 'create'}
218
- expected_params[:format] = false if Devise::Test.rails5?
219
-
220
- assert_recognizes(expected_params, {path: '/htmlonly_admin/password', method: :post})
221
- assert_raise ExpectedRoutingError do
222
- assert_recognizes(expected_params, {path: '/htmlonly_admin/password.xml', method: :post})
223
- end
224
- end
225
-
226
- test 'map with format false for registrations' do
227
- expected_params = {controller: 'devise/registrations', action: 'new'}
228
- expected_params[:format] = false if Devise::Test.rails5?
229
-
230
- assert_recognizes(expected_params, {path: '/htmlonly_admin/sign_up', method: :get})
231
- assert_raise ExpectedRoutingError do
232
- assert_recognizes(expected_params, {path: '/htmlonly_admin/sign_up.xml', method: :get})
233
- end
234
- end
235
-
236
- test 'map with format false for confirmations' do
237
- expected_params = {controller: 'devise/confirmations', action: 'show'}
238
- expected_params[:format] = false if Devise::Test.rails5?
239
-
240
- assert_recognizes(expected_params, {path: '/htmlonly_users/confirmation', method: :get})
241
- assert_raise ExpectedRoutingError do
242
- assert_recognizes(expected_params, {path: '/htmlonly_users/confirmation.xml', method: :get})
243
- end
244
- end
245
-
246
- test 'map with format false for unlocks' do
247
- expected_params = {controller: 'devise/unlocks', action: 'show'}
248
- expected_params[:format] = false if Devise::Test.rails5?
249
-
250
- assert_recognizes(expected_params, {path: '/htmlonly_users/unlock', method: :get})
251
- assert_raise ExpectedRoutingError do
252
- assert_recognizes(expected_params, {path: '/htmlonly_users/unlock.xml', method: :get})
253
- end
254
- end
255
-
256
- test 'map with format false is not permanent' do
257
- assert_equal "/set.xml", @routes.url_helpers.set_path(:xml)
258
- end
259
-
260
- test 'checks if mapping has proper configuration for omniauth callback' do
261
- e = assert_raise ArgumentError do
262
- routes = ActionDispatch::Routing::RouteSet.new
263
- routes.draw do
264
- devise_for :not_omniauthable, class_name: 'Admin', controllers: {omniauth_callbacks: "users/omniauth_callbacks"}
265
- end
266
- end
267
- assert_match "Mapping omniauth_callbacks on a resource that is not omniauthable", e.message
268
- end
269
- end
270
-
271
- class ScopedRoutingTest < ActionController::TestCase
272
- test 'map publisher account' do
273
- assert_recognizes({controller: 'publisher/registrations', action: 'new'}, {path: '/publisher/accounts/sign_up', method: :get})
274
- assert_equal '/publisher/accounts/sign_up', @routes.url_helpers.new_publisher_account_registration_path
275
- end
276
-
277
- test 'map publisher account merges path names' do
278
- assert_recognizes({controller: 'publisher/sessions', action: 'new'}, {path: '/publisher/accounts/get_in', method: :get})
279
- assert_equal '/publisher/accounts/get_in', @routes.url_helpers.new_publisher_account_session_path
280
- end
281
- end
@@ -1,121 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class Rails52Credentials
6
- def credentials
7
- OpenStruct.new(secret_key_base: 'credentials')
8
- end
9
- end
10
-
11
- class Rails52Secrets
12
- def credentials
13
- OpenStruct.new(secret_key_base: nil)
14
- end
15
-
16
- def secrets
17
- OpenStruct.new(secret_key_base: 'secrets')
18
- end
19
- end
20
-
21
- class Rails52Config
22
- def credentials
23
- OpenStruct.new(secret_key_base: nil)
24
- end
25
-
26
- def secrets
27
- OpenStruct.new(secret_key_base: nil)
28
- end
29
-
30
- def config
31
- OpenStruct.new(secret_key_base: 'config')
32
- end
33
- end
34
-
35
- class Rails52SecretKeyBase
36
- def credentials
37
- OpenStruct.new(secret_key_base: nil)
38
- end
39
-
40
- def secrets
41
- OpenStruct.new(secret_key_base: nil)
42
- end
43
-
44
- def config
45
- OpenStruct.new(secret_key_base: nil)
46
- end
47
-
48
- def secret_key_base
49
- 'secret_key_base'
50
- end
51
- end
52
-
53
- class Rails41Secrets
54
- def secrets
55
- OpenStruct.new(secret_key_base: 'secrets')
56
- end
57
-
58
- def config
59
- OpenStruct.new(secret_key_base: nil)
60
- end
61
- end
62
-
63
- class Rails41Config
64
- def secrets
65
- OpenStruct.new(secret_key_base: nil)
66
- end
67
-
68
- def config
69
- OpenStruct.new(secret_key_base: 'config')
70
- end
71
- end
72
-
73
- class Rails40Config
74
- def config
75
- OpenStruct.new(secret_key_base: 'config')
76
- end
77
- end
78
-
79
- class SecretKeyFinderTest < ActiveSupport::TestCase
80
- test "rails 5.2 uses credentials when they're available" do
81
- secret_key_finder = Devise::SecretKeyFinder.new(Rails52Credentials.new)
82
-
83
- assert_equal 'credentials', secret_key_finder.find
84
- end
85
-
86
- test "rails 5.2 uses secrets when credentials are empty" do
87
- secret_key_finder = Devise::SecretKeyFinder.new(Rails52Secrets.new)
88
-
89
- assert_equal 'secrets', secret_key_finder.find
90
- end
91
-
92
- test "rails 5.2 uses config when secrets are empty" do
93
- secret_key_finder = Devise::SecretKeyFinder.new(Rails52Config.new)
94
-
95
- assert_equal 'config', secret_key_finder.find
96
- end
97
-
98
- test "rails 5.2 uses secret_key_base when config is empty" do
99
- secret_key_finder = Devise::SecretKeyFinder.new(Rails52SecretKeyBase.new)
100
-
101
- assert_equal 'secret_key_base', secret_key_finder.find
102
- end
103
-
104
- test "rails 4.1 uses secrets" do
105
- secret_key_finder = Devise::SecretKeyFinder.new(Rails41Secrets.new)
106
-
107
- assert_equal 'secrets', secret_key_finder.find
108
- end
109
-
110
- test "rails 4.1 uses config when secrets are empty" do
111
- secret_key_finder = Devise::SecretKeyFinder.new(Rails41Config.new)
112
-
113
- assert_equal 'config', secret_key_finder.find
114
- end
115
-
116
- test "rails 4.0 uses config" do
117
- secret_key_finder = Devise::SecretKeyFinder.new(Rails40Config.new)
118
-
119
- assert_equal 'config', secret_key_finder.find
120
- end
121
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Since webrat uses ActionController::RecordIdentifier class that was moved to
4
- # ActionView namespace in Rails 4.1+
5
-
6
- unless defined?(ActionController::RecordIdentifier)
7
- require 'action_view/record_identifier'
8
-
9
- module ActionController
10
- RecordIdentifier = ActionView::RecordIdentifier
11
- end
12
- end