Bring back `Devise.activerecord51? and deprecate it

Even though this is considered an internal / non-public / nodoc method,
it seems some libraries relied on it internally, causing some breakage.

Known libraries so far are `devise-security` and
`devise-pwned_password`.

Closes #5580
This commit is contained in:
Carlos Antonio da Silva
2023-04-03 09:18:34 -03:00
parent 3926e6d9eb
commit 4f849f4fa9
3 changed files with 14 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
### Unreleased
* deprecations
* Bring back `Devise.activerecord51?` and deprecate it, in order to avoid breakage with some libraries that apparently relied on it.
### 4.9.1 - 2023-03-31

View File

@@ -520,6 +520,14 @@ module Devise
b.each_byte { |byte| res |= byte ^ l.shift }
res == 0
end
def self.activerecord51? # :nodoc:
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
[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.
DEPRECATION
defined?(ActiveRecord) && ActiveRecord.gem_version >= Gem::Version.new("5.1.x")
end
end
require 'warden'

View File

@@ -106,4 +106,8 @@ class DeviseTest < ActiveSupport::TestCase
assert_no_match Devise.email_regexp, email
end
end
test 'Devise.activerecord51? deprecation' do
assert_deprecated { Devise.activerecord51? }
end
end