From 4f849f4fa9a74608a9447806179c8cbb19bd7b38 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Mon, 3 Apr 2023 09:18:34 -0300 Subject: [PATCH] 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 --- CHANGELOG.md | 3 ++- lib/devise.rb | 8 ++++++++ test/devise_test.rb | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de772cd6..8746e5e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/devise.rb b/lib/devise.rb index ca1130d9..b8677e79 100644 --- a/lib/devise.rb +++ b/lib/devise.rb @@ -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' diff --git a/test/devise_test.rb b/test/devise_test.rb index 423daf37..54ed9867 100644 --- a/test/devise_test.rb +++ b/test/devise_test.rb @@ -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