mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-09 14:58:05 -05:00
Merge pull request #5583 from etiennebarrie/deprecator
Use a dedicated ActiveSupport::Deprecation
This commit is contained in:
committed by
Carlos Antonio da Silva
parent
34cb23ed9c
commit
a7d64ae313
@@ -4,7 +4,7 @@ module DeviseHelper
|
|||||||
# Retain this method for backwards compatibility, deprecated in favor of modifying the
|
# Retain this method for backwards compatibility, deprecated in favor of modifying the
|
||||||
# devise/shared/error_messages partial.
|
# devise/shared/error_messages partial.
|
||||||
def devise_error_messages!
|
def devise_error_messages!
|
||||||
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
|
Devise.deprecator.warn <<-DEPRECATION.strip_heredoc
|
||||||
[Devise] `DeviseHelper#devise_error_messages!` is deprecated and will be
|
[Devise] `DeviseHelper#devise_error_messages!` is deprecated and will be
|
||||||
removed in the next major version.
|
removed in the next major version.
|
||||||
|
|
||||||
|
|||||||
@@ -521,8 +521,12 @@ module Devise
|
|||||||
res == 0
|
res == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.deprecator
|
||||||
|
@deprecator ||= ActiveSupport::Deprecation.new("5.0", "Devise")
|
||||||
|
end
|
||||||
|
|
||||||
def self.activerecord51? # :nodoc:
|
def self.activerecord51? # :nodoc:
|
||||||
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
|
deprecator.warn <<-DEPRECATION.strip_heredoc
|
||||||
[Devise] `Devise.activerecord51?` is deprecated and will be removed in the next major version.
|
[Devise] `Devise.activerecord51?` is deprecated and will be removed in the next major version.
|
||||||
It is a non-public method that's no longer used internally, but that other libraries have been relying on.
|
It is a non-public method that's no longer used internally, but that other libraries have been relying on.
|
||||||
DEPRECATION
|
DEPRECATION
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ module Devise
|
|||||||
expire_data_after_sign_in!
|
expire_data_after_sign_in!
|
||||||
|
|
||||||
if options[:bypass]
|
if options[:bypass]
|
||||||
ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc, caller)
|
Devise.deprecator.warn(<<-DEPRECATION.strip_heredoc, caller)
|
||||||
[Devise] bypass option is deprecated and it will be removed in future version of Devise.
|
[Devise] bypass option is deprecated and it will be removed in future version of Devise.
|
||||||
Please use bypass_sign_in method instead.
|
Please use bypass_sign_in method instead.
|
||||||
Example:
|
Example:
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ module Devise
|
|||||||
:remember_token, :unconfirmed_email, :failed_attempts, :unlock_token, :locked_at]
|
:remember_token, :unconfirmed_email, :failed_attempts, :unlock_token, :locked_at]
|
||||||
|
|
||||||
include Devise::DeprecatedConstantAccessor
|
include Devise::DeprecatedConstantAccessor
|
||||||
deprecate_constant "BLACKLIST_FOR_SERIALIZATION", "Devise::Models::Authenticatable::UNSAFE_ATTRIBUTES_FOR_SERIALIZATION"
|
deprecate_constant "BLACKLIST_FOR_SERIALIZATION", "Devise::Models::Authenticatable::UNSAFE_ATTRIBUTES_FOR_SERIALIZATION", deprecator: Devise.deprecator
|
||||||
|
|
||||||
included do
|
included do
|
||||||
class_attribute :devise_modules, instance_writer: false
|
class_attribute :devise_modules, instance_writer: false
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ module Devise
|
|||||||
# is also rejected as long as it is also blank.
|
# is also rejected as long as it is also blank.
|
||||||
def update_with_password(params, *options)
|
def update_with_password(params, *options)
|
||||||
if options.present?
|
if options.present?
|
||||||
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
|
Devise.deprecator.warn <<-DEPRECATION.strip_heredoc
|
||||||
[Devise] The second argument of `DatabaseAuthenticatable#update_with_password`
|
[Devise] The second argument of `DatabaseAuthenticatable#update_with_password`
|
||||||
(`options`) is deprecated and it will be removed in the next major version.
|
(`options`) is deprecated and it will be removed in the next major version.
|
||||||
It was added to support a feature deprecated in Rails 4, so you can safely remove it
|
It was added to support a feature deprecated in Rails 4, so you can safely remove it
|
||||||
@@ -128,7 +128,7 @@ module Devise
|
|||||||
#
|
#
|
||||||
def update_without_password(params, *options)
|
def update_without_password(params, *options)
|
||||||
if options.present?
|
if options.present?
|
||||||
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
|
Devise.deprecator.warn <<-DEPRECATION.strip_heredoc
|
||||||
[Devise] The second argument of `DatabaseAuthenticatable#update_without_password`
|
[Devise] The second argument of `DatabaseAuthenticatable#update_without_password`
|
||||||
(`options`) is deprecated and it will be removed in the next major version.
|
(`options`) is deprecated and it will be removed in the next major version.
|
||||||
It was added to support a feature deprecated in Rails 4, so you can safely remove it
|
It was added to support a feature deprecated in Rails 4, so you can safely remove it
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ module Devise
|
|||||||
app.reload_routes! if Devise.reload_routes
|
app.reload_routes! if Devise.reload_routes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
initializer "devise.deprecator" do |app|
|
||||||
|
app.deprecators[:devise] = Devise.deprecator if app.respond_to?(:deprecators)
|
||||||
|
end
|
||||||
|
|
||||||
initializer "devise.url_helpers" do
|
initializer "devise.url_helpers" do
|
||||||
Devise.include_helpers(Devise::Controllers)
|
Devise.include_helpers(Devise::Controllers)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ module Devise
|
|||||||
scope = resource
|
scope = resource
|
||||||
resource = deprecated
|
resource = deprecated
|
||||||
|
|
||||||
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
|
Devise.deprecator.warn <<-DEPRECATION.strip_heredoc
|
||||||
[Devise] sign_in(:#{scope}, resource) on controller tests is deprecated and will be removed from Devise.
|
[Devise] sign_in(:#{scope}, resource) on controller tests is deprecated and will be removed from Devise.
|
||||||
Please use sign_in(resource, scope: :#{scope}) instead.
|
Please use sign_in(resource, scope: :#{scope}) instead.
|
||||||
DEPRECATION
|
DEPRECATION
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ module Devise
|
|||||||
module TestHelpers
|
module TestHelpers
|
||||||
def self.included(base)
|
def self.included(base)
|
||||||
base.class_eval do
|
base.class_eval do
|
||||||
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
|
Devise.deprecator.warn <<-DEPRECATION.strip_heredoc
|
||||||
[Devise] including `Devise::TestHelpers` is deprecated and will be removed from Devise.
|
[Devise] including `Devise::TestHelpers` is deprecated and will be removed from Devise.
|
||||||
For controller tests, please include `Devise::Test::ControllerHelpers` instead.
|
For controller tests, please include `Devise::Test::ControllerHelpers` instead.
|
||||||
DEPRECATION
|
DEPRECATION
|
||||||
|
|||||||
@@ -108,6 +108,8 @@ class DeviseTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
test 'Devise.activerecord51? deprecation' do
|
test 'Devise.activerecord51? deprecation' do
|
||||||
assert_deprecated { Devise.activerecord51? }
|
assert_deprecated("`Devise.activerecord51?` is deprecated", Devise.deprecator) do
|
||||||
|
Devise.activerecord51?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ class SerializableTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
test 'constant `BLACKLIST_FOR_SERIALIZATION` is deprecated' do
|
test 'constant `BLACKLIST_FOR_SERIALIZATION` is deprecated' do
|
||||||
assert_deprecated { Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION }
|
assert_deprecated("Devise::Models::Authenticatable::UNSAFE_ATTRIBUTES_FOR_SERIALIZATION", Devise.deprecator) do
|
||||||
|
Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_key(key, subject)
|
def assert_key(key, subject)
|
||||||
|
|||||||
@@ -8,4 +8,10 @@ class RailsTest < ActiveSupport::TestCase
|
|||||||
assert_equal :load_config_initializers, initializer.after
|
assert_equal :load_config_initializers, initializer.after
|
||||||
assert_equal :build_middleware_stack, initializer.before
|
assert_equal :build_middleware_stack, initializer.before
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if Devise::Test.rails71_and_up?
|
||||||
|
test 'deprecator is added to application deprecators' do
|
||||||
|
assert_not_nil Rails.application.deprecators[:devise]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -23,6 +23,19 @@ end
|
|||||||
if ActiveSupport.respond_to?(:test_order)
|
if ActiveSupport.respond_to?(:test_order)
|
||||||
ActiveSupport.test_order = :random
|
ActiveSupport.test_order = :random
|
||||||
end
|
end
|
||||||
|
class ActiveSupport::TestCase
|
||||||
|
if ActiveSupport.version < Gem::Version.new("5.0")
|
||||||
|
def assert_deprecated(match, deprecator)
|
||||||
|
super(match) do
|
||||||
|
behavior = deprecator.behavior
|
||||||
|
deprecator.behavior = ActiveSupport::Deprecation.behavior
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
deprecator.behavior = behavior
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
OmniAuth.config.logger = Logger.new('/dev/null')
|
OmniAuth.config.logger = Logger.new('/dev/null')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user