devise 4.3.0 → 4.4.2

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 (217) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +15 -5
  3. data/CHANGELOG.md +41 -0
  4. data/Gemfile +2 -3
  5. data/Gemfile.lock +3 -4
  6. data/ISSUE_TEMPLATE.md +19 -0
  7. data/README.md +97 -4
  8. data/Rakefile +1 -0
  9. data/app/controllers/devise/confirmations_controller.rb +2 -0
  10. data/app/controllers/devise/omniauth_callbacks_controller.rb +3 -1
  11. data/app/controllers/devise/passwords_controller.rb +2 -0
  12. data/app/controllers/devise/registrations_controller.rb +5 -3
  13. data/app/controllers/devise/sessions_controller.rb +3 -1
  14. data/app/controllers/devise/unlocks_controller.rb +2 -0
  15. data/app/controllers/devise_controller.rb +2 -0
  16. data/app/helpers/devise_helper.rb +2 -0
  17. data/app/mailers/devise/mailer.rb +2 -0
  18. data/app/views/devise/confirmations/new.html.erb +1 -1
  19. data/app/views/devise/passwords/new.html.erb +1 -1
  20. data/app/views/devise/registrations/edit.html.erb +1 -1
  21. data/app/views/devise/registrations/new.html.erb +1 -1
  22. data/app/views/devise/sessions/new.html.erb +1 -1
  23. data/app/views/devise/unlocks/new.html.erb +1 -1
  24. data/devise.gemspec +3 -1
  25. data/gemfiles/Gemfile.rails-4.1-stable +3 -1
  26. data/gemfiles/Gemfile.rails-4.1-stable.lock +4 -4
  27. data/gemfiles/Gemfile.rails-4.2-stable +3 -1
  28. data/gemfiles/Gemfile.rails-4.2-stable.lock +4 -4
  29. data/gemfiles/Gemfile.rails-5.0-stable +2 -3
  30. data/gemfiles/Gemfile.rails-5.0-stable.lock +3 -4
  31. data/gemfiles/Gemfile.rails-5.2-rc1 +26 -0
  32. data/gemfiles/Gemfile.rails-5.2-rc1.lock +201 -0
  33. data/guides/bug_report_templates/integration_test.rb +2 -0
  34. data/lib/devise/controllers/helpers.rb +2 -0
  35. data/lib/devise/controllers/rememberable.rb +2 -0
  36. data/lib/devise/controllers/scoped_views.rb +2 -0
  37. data/lib/devise/controllers/sign_in_out.rb +6 -1
  38. data/lib/devise/controllers/store_location.rb +24 -6
  39. data/lib/devise/controllers/url_helpers.rb +2 -0
  40. data/lib/devise/delegator.rb +2 -0
  41. data/lib/devise/encryptor.rb +2 -0
  42. data/lib/devise/failure_app.rb +2 -0
  43. data/lib/devise/hooks/activatable.rb +2 -0
  44. data/lib/devise/hooks/csrf_cleaner.rb +2 -0
  45. data/lib/devise/hooks/forgetable.rb +2 -0
  46. data/lib/devise/hooks/lockable.rb +2 -0
  47. data/lib/devise/hooks/proxy.rb +2 -0
  48. data/lib/devise/hooks/rememberable.rb +2 -0
  49. data/lib/devise/hooks/timeoutable.rb +2 -0
  50. data/lib/devise/hooks/trackable.rb +2 -0
  51. data/lib/devise/mailers/helpers.rb +2 -0
  52. data/lib/devise/mapping.rb +2 -0
  53. data/lib/devise/models/authenticatable.rb +4 -2
  54. data/lib/devise/models/confirmable.rb +3 -1
  55. data/lib/devise/models/database_authenticatable.rb +3 -1
  56. data/lib/devise/models/lockable.rb +8 -2
  57. data/lib/devise/models/omniauthable.rb +2 -0
  58. data/lib/devise/models/recoverable.rb +2 -0
  59. data/lib/devise/models/registerable.rb +2 -0
  60. data/lib/devise/models/rememberable.rb +3 -1
  61. data/lib/devise/models/timeoutable.rb +2 -0
  62. data/lib/devise/models/trackable.rb +7 -0
  63. data/lib/devise/models/validatable.rb +3 -1
  64. data/lib/devise/models.rb +2 -0
  65. data/lib/devise/modules.rb +2 -0
  66. data/lib/devise/omniauth/config.rb +2 -0
  67. data/lib/devise/omniauth/url_helpers.rb +2 -0
  68. data/lib/devise/omniauth.rb +2 -0
  69. data/lib/devise/orm/active_record.rb +2 -0
  70. data/lib/devise/orm/mongoid.rb +2 -0
  71. data/lib/devise/parameter_filter.rb +2 -0
  72. data/lib/devise/parameter_sanitizer.rb +2 -0
  73. data/lib/devise/rails/routes.rb +2 -0
  74. data/lib/devise/rails/warden_compat.rb +2 -0
  75. data/lib/devise/rails.rb +5 -1
  76. data/lib/devise/strategies/authenticatable.rb +2 -0
  77. data/lib/devise/strategies/base.rb +2 -0
  78. data/lib/devise/strategies/database_authenticatable.rb +2 -0
  79. data/lib/devise/strategies/rememberable.rb +2 -0
  80. data/lib/devise/test/controller_helpers.rb +3 -0
  81. data/lib/devise/test/integration_helpers.rb +2 -0
  82. data/lib/devise/test_helpers.rb +2 -0
  83. data/lib/devise/time_inflector.rb +2 -0
  84. data/lib/devise/token_generator.rb +2 -0
  85. data/lib/devise/version.rb +3 -1
  86. data/lib/devise.rb +3 -1
  87. data/lib/generators/active_record/devise_generator.rb +15 -2
  88. data/lib/generators/active_record/templates/migration.rb +3 -1
  89. data/lib/generators/active_record/templates/migration_existing.rb +2 -0
  90. data/lib/generators/devise/controllers_generator.rb +2 -0
  91. data/lib/generators/devise/devise_generator.rb +4 -2
  92. data/lib/generators/devise/install_generator.rb +2 -0
  93. data/lib/generators/devise/orm_helpers.rb +7 -1
  94. data/lib/generators/devise/views_generator.rb +7 -8
  95. data/lib/generators/mongoid/devise_generator.rb +2 -0
  96. data/lib/generators/templates/controllers/confirmations_controller.rb +2 -0
  97. data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +2 -0
  98. data/lib/generators/templates/controllers/passwords_controller.rb +2 -0
  99. data/lib/generators/templates/controllers/registrations_controller.rb +2 -0
  100. data/lib/generators/templates/controllers/sessions_controller.rb +2 -0
  101. data/lib/generators/templates/controllers/unlocks_controller.rb +2 -0
  102. data/lib/generators/templates/devise.rb +6 -0
  103. data/test/controllers/custom_registrations_controller_test.rb +2 -0
  104. data/test/controllers/custom_strategy_test.rb +2 -0
  105. data/test/controllers/helper_methods_test.rb +2 -0
  106. data/test/controllers/helpers_test.rb +2 -0
  107. data/test/controllers/inherited_controller_i18n_messages_test.rb +2 -0
  108. data/test/controllers/internal_helpers_test.rb +2 -0
  109. data/test/controllers/load_hooks_controller_test.rb +2 -0
  110. data/test/controllers/passwords_controller_test.rb +2 -0
  111. data/test/controllers/sessions_controller_test.rb +2 -0
  112. data/test/controllers/url_helpers_test.rb +2 -0
  113. data/test/delegator_test.rb +2 -0
  114. data/test/devise_test.rb +2 -0
  115. data/test/failure_app_test.rb +2 -0
  116. data/test/generators/active_record_generator_test.rb +47 -0
  117. data/test/generators/controllers_generator_test.rb +2 -0
  118. data/test/generators/devise_generator_test.rb +2 -0
  119. data/test/generators/install_generator_test.rb +2 -0
  120. data/test/generators/mongoid_generator_test.rb +2 -0
  121. data/test/generators/views_generator_test.rb +2 -0
  122. data/test/helpers/devise_helper_test.rb +2 -0
  123. data/test/integration/authenticatable_test.rb +9 -1
  124. data/test/integration/confirmable_test.rb +2 -0
  125. data/test/integration/database_authenticatable_test.rb +2 -0
  126. data/test/integration/http_authenticatable_test.rb +8 -0
  127. data/test/integration/lockable_test.rb +5 -3
  128. data/test/integration/mounted_engine_test.rb +2 -0
  129. data/test/integration/omniauthable_test.rb +13 -0
  130. data/test/integration/recoverable_test.rb +2 -0
  131. data/test/integration/registerable_test.rb +2 -0
  132. data/test/integration/rememberable_test.rb +3 -1
  133. data/test/integration/timeoutable_test.rb +2 -0
  134. data/test/integration/trackable_test.rb +7 -0
  135. data/test/mailers/confirmation_instructions_test.rb +2 -0
  136. data/test/mailers/email_changed_test.rb +2 -0
  137. data/test/mailers/mailer_test.rb +2 -0
  138. data/test/mailers/reset_password_instructions_test.rb +2 -0
  139. data/test/mailers/unlock_instructions_test.rb +2 -0
  140. data/test/mapping_test.rb +2 -0
  141. data/test/models/authenticatable_test.rb +2 -0
  142. data/test/models/confirmable_test.rb +13 -0
  143. data/test/models/database_authenticatable_test.rb +2 -0
  144. data/test/models/lockable_test.rb +2 -0
  145. data/test/models/omniauthable_test.rb +2 -0
  146. data/test/models/recoverable_test.rb +2 -0
  147. data/test/models/registerable_test.rb +2 -0
  148. data/test/models/rememberable_test.rb +2 -0
  149. data/test/models/serializable_test.rb +6 -0
  150. data/test/models/timeoutable_test.rb +2 -0
  151. data/test/models/trackable_test.rb +21 -0
  152. data/test/models/validatable_test.rb +4 -2
  153. data/test/models_test.rb +2 -0
  154. data/test/omniauth/config_test.rb +2 -0
  155. data/test/omniauth/url_helpers_test.rb +2 -0
  156. data/test/orm/active_record.rb +8 -1
  157. data/test/orm/mongoid.rb +3 -1
  158. data/test/parameter_sanitizer_test.rb +2 -0
  159. data/test/rails_app/app/active_record/admin.rb +2 -0
  160. data/test/rails_app/app/active_record/shim.rb +2 -0
  161. data/test/rails_app/app/active_record/user.rb +13 -0
  162. data/test/rails_app/app/active_record/user_on_engine.rb +2 -0
  163. data/test/rails_app/app/active_record/user_on_main_app.rb +2 -0
  164. data/test/rails_app/app/active_record/user_with_validations.rb +12 -0
  165. data/test/rails_app/app/active_record/user_without_email.rb +2 -0
  166. data/test/rails_app/app/controllers/admins/sessions_controller.rb +2 -0
  167. data/test/rails_app/app/controllers/admins_controller.rb +2 -0
  168. data/test/rails_app/app/controllers/application_controller.rb +2 -0
  169. data/test/rails_app/app/controllers/application_with_fake_engine.rb +2 -0
  170. data/test/rails_app/app/controllers/custom/registrations_controller.rb +2 -0
  171. data/test/rails_app/app/controllers/home_controller.rb +2 -0
  172. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +2 -0
  173. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +2 -0
  174. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +2 -0
  175. data/test/rails_app/app/controllers/users_controller.rb +2 -0
  176. data/test/rails_app/app/helpers/application_helper.rb +2 -0
  177. data/test/rails_app/app/mailers/users/from_proc_mailer.rb +2 -0
  178. data/test/rails_app/app/mailers/users/mailer.rb +2 -0
  179. data/test/rails_app/app/mailers/users/reply_to_mailer.rb +2 -0
  180. data/test/rails_app/app/mongoid/admin.rb +2 -0
  181. data/test/rails_app/app/mongoid/shim.rb +2 -0
  182. data/test/rails_app/app/mongoid/user.rb +11 -0
  183. data/test/rails_app/app/mongoid/user_on_engine.rb +2 -0
  184. data/test/rails_app/app/mongoid/user_on_main_app.rb +2 -0
  185. data/test/rails_app/app/mongoid/user_with_validations.rb +37 -0
  186. data/test/rails_app/app/mongoid/user_without_email.rb +2 -0
  187. data/test/rails_app/config/application.rb +6 -2
  188. data/test/rails_app/config/boot.rb +8 -1
  189. data/test/rails_app/config/environment.rb +2 -0
  190. data/test/rails_app/config/environments/development.rb +2 -0
  191. data/test/rails_app/config/environments/production.rb +2 -0
  192. data/test/rails_app/config/environments/test.rb +2 -0
  193. data/test/rails_app/config/initializers/backtrace_silencers.rb +2 -0
  194. data/test/rails_app/config/initializers/devise.rb +2 -0
  195. data/test/rails_app/config/initializers/inflections.rb +2 -0
  196. data/test/rails_app/config/initializers/secret_token.rb +2 -0
  197. data/test/rails_app/config/initializers/session_store.rb +2 -0
  198. data/test/rails_app/config/routes.rb +2 -0
  199. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +2 -0
  200. data/test/rails_app/db/schema.rb +2 -0
  201. data/test/rails_app/lib/shared_admin.rb +2 -0
  202. data/test/rails_app/lib/shared_user.rb +2 -0
  203. data/test/rails_app/lib/shared_user_without_email.rb +2 -0
  204. data/test/rails_app/lib/shared_user_without_omniauth.rb +2 -0
  205. data/test/rails_test.rb +2 -0
  206. data/test/routes_test.rb +2 -0
  207. data/test/support/action_controller/record_identifier.rb +2 -0
  208. data/test/support/assertions.rb +2 -0
  209. data/test/support/helpers.rb +6 -0
  210. data/test/support/http_method_compatibility.rb +2 -0
  211. data/test/support/integration.rb +3 -0
  212. data/test/support/webrat/integrations/rails.rb +2 -0
  213. data/test/test/controller_helpers_test.rb +8 -1
  214. data/test/test/integration_helpers_test.rb +2 -0
  215. data/test/test_helper.rb +2 -0
  216. data/test/test_models.rb +2 -0
  217. metadata +12 -5
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class SessionTimeoutTest < Devise::IntegrationTest
@@ -1,6 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class TrackableHooksTest < Devise::IntegrationTest
6
+ test "trackable should not run model validations" do
7
+ sign_in_as_user
8
+
9
+ refute User.validations_performed
10
+ end
4
11
 
5
12
  test "current and last sign in timestamps are updated on each sign in" do
6
13
  user = create_user
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class ConfirmationInstructionsTest < ActionMailer::TestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class EmailChangedTest < ActionMailer::TestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "test_helper"
2
4
 
3
5
  class MailerTest < ActionMailer::TestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class ResetPasswordInstructionsTest < ActionMailer::TestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class UnlockInstructionsTest < ActionMailer::TestCase
data/test/mapping_test.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class FakeRequest < Struct.new(:path_info, :params)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class AuthenticatableTest < ActiveSupport::TestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class ConfirmableTest < ActiveSupport::TestCase
@@ -6,6 +8,17 @@ class ConfirmableTest < ActiveSupport::TestCase
6
8
  setup_mailer
7
9
  end
8
10
 
11
+ test 'should set callbacks to send the mail' do
12
+ if DEVISE_ORM == :active_record
13
+ defined_callbacks = User._commit_callbacks.map(&:filter)
14
+ assert_includes defined_callbacks, :send_on_create_confirmation_instructions
15
+ assert_includes defined_callbacks, :send_reconfirmation_instructions
16
+ elsif DEVISE_ORM == :mongoid
17
+ assert_includes User._create_callbacks.map(&:filter), :send_on_create_confirmation_instructions
18
+ assert_includes User._update_callbacks.map(&:filter), :send_reconfirmation_instructions
19
+ end
20
+ end
21
+
9
22
  test 'should generate confirmation token after creating a record' do
10
23
  assert_nil new_user.confirmation_token
11
24
  assert_not_nil create_user.confirmation_token
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
  require 'test_models'
3
5
  require 'digest/sha1'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class LockableTest < ActiveSupport::TestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class OmniauthableTest < ActiveSupport::TestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class RecoverableTest < ActiveSupport::TestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class RegisterableTest < ActiveSupport::TestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class RememberableTest < ActiveSupport::TestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class SerializableTest < ActiveSupport::TestCase
@@ -40,6 +42,10 @@ class SerializableTest < ActiveSupport::TestCase
40
42
  assert_no_match(/confirmation_token/, @user.inspect)
41
43
  end
42
44
 
45
+ test 'should accept frozen options' do
46
+ assert_key "username", @user.as_json({only: :username}.freeze)["user"]
47
+ end
48
+
43
49
  def assert_key(key, subject)
44
50
  assert subject.key?(key), "Expected #{subject.inspect} to have key #{key.inspect}"
45
51
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class TimeoutableTest < ActiveSupport::TestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class TrackableTest < ActiveSupport::TestCase
@@ -38,4 +40,23 @@ class TrackableTest < ActiveSupport::TestCase
38
40
  assert_nil user.last_sign_in_at
39
41
  assert_equal 0, user.sign_in_count
40
42
  end
43
+
44
+ test "update_tracked_fields! should not persist invalid records" do
45
+ user = UserWithValidations.new
46
+ request = mock
47
+ request.stubs(:remote_ip).returns("127.0.0.1")
48
+
49
+ assert_not user.update_tracked_fields!(request)
50
+ assert_not user.persisted?
51
+ end
52
+
53
+ test "update_tracked_fields! should not run model validations" do
54
+ user = User.new
55
+ request = mock
56
+ request.stubs(:remote_ip).returns("127.0.0.1")
57
+
58
+ user.expects(:after_validation_callback).never
59
+
60
+ assert_not user.update_tracked_fields!(request)
61
+ end
41
62
  end
@@ -1,4 +1,6 @@
1
1
  # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
2
4
  require 'test_helper'
3
5
 
4
6
  class ValidatableTest < ActiveSupport::TestCase
@@ -31,7 +33,7 @@ class ValidatableTest < ActiveSupport::TestCase
31
33
 
32
34
  %w{invalid_email_format 123 $$$ () ☃}.each do |email|
33
35
  user.email = email
34
- assert user.invalid?, 'should be invalid with email ' << email
36
+ assert user.invalid?, "should be invalid with email #{email}"
35
37
  assert_equal 'is invalid', user.errors[:email].join
36
38
  end
37
39
 
@@ -42,7 +44,7 @@ class ValidatableTest < ActiveSupport::TestCase
42
44
  test 'should accept valid emails' do
43
45
  %w(a.b.c@example.com test_mail@gmail.com any@any.net email@test.br 123@mail.test 1☃3@mail.test).each do |email|
44
46
  user = new_user(email: email)
45
- assert user.valid?, 'should be valid with email ' << email
47
+ assert user.valid?, "should be valid with email #{email}"
46
48
  assert_blank user.errors[:email]
47
49
  end
48
50
  end
data/test/models_test.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
  require 'test_models'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class OmniAuthConfigTest < ActiveSupport::TestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class OmniAuthRoutesTest < ActionController::TestCase
@@ -1,8 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ActiveRecord::Migration.verbose = false
2
4
  ActiveRecord::Base.logger = Logger.new(nil)
3
5
  ActiveRecord::Base.include_root_in_json = true
4
6
 
5
- ActiveRecord::Migrator.migrate(File.expand_path("../../rails_app/db/migrate/", __FILE__))
7
+ migrate_path = File.expand_path("../../rails_app/db/migrate/", __FILE__)
8
+ if Devise::Test.rails52?
9
+ ActiveRecord::MigrationContext.new(migrate_path).migrate
10
+ else
11
+ ActiveRecord::Migrator.migrate(migrate_path)
12
+ end
6
13
 
7
14
  class ActiveSupport::TestCase
8
15
  if Devise::Test.rails5?
data/test/orm/mongoid.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mongoid/version'
2
4
 
3
5
  Mongoid.configure do |config|
@@ -8,6 +10,6 @@ end
8
10
 
9
11
  class ActiveSupport::TestCase
10
12
  setup do
11
- Mongoid.purge!
13
+ Mongoid.default_session.drop
12
14
  end
13
15
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
  require 'devise/parameter_sanitizer'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'shared_admin'
2
4
 
3
5
  class Admin < ActiveRecord::Base
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Shim
2
4
  end
@@ -1,7 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'shared_user'
2
4
 
3
5
  class User < ActiveRecord::Base
4
6
  include Shim
5
7
  include SharedUser
6
8
  include ActiveModel::Serializers::Xml if Devise::Test.rails5?
9
+
10
+ validates :sign_in_count, presence: true
11
+
12
+ cattr_accessor :validations_performed
13
+
14
+ after_validation :after_validation_callback
15
+
16
+ def after_validation_callback
17
+ # used to check in our test if the validations were called
18
+ @@validations_performed = true
19
+ end
7
20
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'shared_user_without_omniauth'
2
4
 
3
5
  class UserOnEngine < ActiveRecord::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'shared_user_without_omniauth'
2
4
 
3
5
  class UserOnMainApp < ActiveRecord::Base
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'shared_user'
4
+
5
+ class UserWithValidations < ActiveRecord::Base
6
+ self.table_name = 'users'
7
+ include Shim
8
+ include SharedUser
9
+
10
+ validates :email, presence: true
11
+ end
12
+
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "shared_user_without_email"
2
4
 
3
5
  class UserWithoutEmail < ActiveRecord::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Admins::SessionsController < Devise::SessionsController
2
4
  def new
3
5
  flash[:special] = "Welcome to #{controller_path.inspect} controller!"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AdminsController < ApplicationController
2
4
  before_action :authenticate_admin!
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Filters added to this controller apply to all controllers in the application.
2
4
  # Likewise, all the methods added will be available for all controllers.
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ApplicationWithFakeEngine < ApplicationController
2
4
  private
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Custom::RegistrationsController < Devise::RegistrationsController
2
4
  def new
3
5
  super do |resource|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class HomeController < ApplicationController
2
4
  def index
3
5
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Publisher::RegistrationsController < ApplicationController
2
4
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Publisher::SessionsController < ApplicationController
2
4
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
2
4
  def facebook
3
5
  data = request.respond_to?(:get_header) ? request.get_header("omniauth.auth") : request.env["omniauth.auth"]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class UsersController < ApplicationController
2
4
  prepend_before_action :current_user, only: :exhibit
3
5
  before_action :authenticate_user!, except: [:accept, :exhibit]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Methods added to this helper will be available to all templates in the application.
2
4
  module ApplicationHelper
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Users::FromProcMailer < Devise::Mailer
2
4
  default from: proc { 'custom@example.com' }
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Users::Mailer < Devise::Mailer
2
4
  default from: 'custom@example.com'
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Users::ReplyToMailer < Devise::Mailer
2
4
  default from: 'custom@example.com'
3
5
  default reply_to: 'custom_reply_to@example.com'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'shared_admin'
2
4
 
3
5
  class Admin
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Shim
2
4
  extend ::ActiveSupport::Concern
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'shared_user'
2
4
 
3
5
  class User
@@ -36,4 +38,13 @@ class User
36
38
  field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
37
39
  field :unlock_token, type: String # Only if unlock strategy is :email or :both
38
40
  field :locked_at, type: Time
41
+
42
+ cattr_accessor :validations_performed
43
+
44
+ after_validation :after_validation_callback
45
+
46
+ def after_validation_callback
47
+ # used to check in our test if the validations were called
48
+ @@validations_performed = true
49
+ end
39
50
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'shared_user_without_omniauth'
2
4
 
3
5
  class UserOnEngine
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'shared_user_without_omniauth'
2
4
 
3
5
  class UserOnMainApp
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "shared_user"
4
+
5
+ class UserWithValidations
6
+ include Mongoid::Document
7
+ include Shim
8
+ include SharedUser
9
+
10
+ field :username, type: String
11
+ field :facebook_token, type: String
12
+
13
+ ## Database authenticatable
14
+ field :email, type: String, default: ""
15
+ field :encrypted_password, type: String, default: ""
16
+
17
+ ## Recoverable
18
+ field :reset_password_token, type: String
19
+ field :reset_password_sent_at, type: Time
20
+
21
+ ## Rememberable
22
+ field :remember_created_at, type: Time
23
+
24
+ ## Trackable
25
+ field :sign_in_count, type: Integer, default: 0
26
+ field :current_sign_in_at, type: Time
27
+ field :last_sign_in_at, type: Time
28
+ field :current_sign_in_ip, type: String
29
+ field :last_sign_in_ip, type: String
30
+
31
+ ## Lockable
32
+ field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
33
+ field :unlock_token, type: String # Only if unlock strategy is :email or :both
34
+ field :locked_at, type: Time
35
+
36
+ validates :email, presence: true
37
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "shared_user_without_email"
2
4
 
3
5
  class UserWithoutEmail
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.expand_path('../boot', __FILE__)
2
4
 
3
5
  require "action_controller/railtie"
@@ -31,8 +33,10 @@ module RailsApp
31
33
  # config.assets.enabled = false
32
34
 
33
35
  config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
34
-
35
- if DEVISE_ORM == :active_record && (Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 2)
36
+ rails_version = Gem::Version.new(Rails.version)
37
+ if DEVISE_ORM == :active_record &&
38
+ rails_version >= Gem::Version.new('4.2.0') &&
39
+ rails_version < Gem::Version.new('5.1.0')
36
40
  config.active_record.raise_in_transactional_callbacks = true
37
41
  end
38
42
 
@@ -1,10 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  unless defined?(DEVISE_ORM)
2
4
  DEVISE_ORM = (ENV["DEVISE_ORM"] || :active_record).to_sym
3
5
  end
4
6
 
5
7
  module Devise
6
8
  module Test
7
- # Detection for minor differences between Rails 4 and 5, and 5.1 in tests.
9
+ # Detection for minor differences between Rails 4 and 5, 5.1, and 5.2 in tests.
10
+
11
+ def self.rails52?
12
+ Rails.version.start_with? '5.2'
13
+ end
14
+
8
15
  def self.rails51?
9
16
  Rails.version.start_with? '5.1'
10
17
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Load the rails application.
2
4
  require File.expand_path('../application', __FILE__)
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RailsApp::Application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RailsApp::Application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RailsApp::Application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "omniauth-facebook"
2
4
  require "omniauth-openid"
3
5
 
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ActiveSupport::Inflector.inflections do |inflect|
2
4
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  config = Rails.application.config
2
4
 
3
5
  config.secret_key_base = 'd588e99efff13a86461fd6ab82327823ad2f8feb5dc217ce652cdd9f0dfc5eb4b5a62a92d24d2574d7d51dfb1ea8dd453ea54e00cf672159a13104a135422a10'
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RailsApp::Application.config.session_store :cookie_store, key: '_rails_app_session'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.routes.draw do
2
4
  # Resources for testing
3
5
  resources :users, only: [:index] do