From bf522f806cadc9d2f18f263034fa00a57c5b7367 Mon Sep 17 00:00:00 2001
From: Takashi Kato <tohosaku@users.osdn.me>
Date: Mon, 19 Aug 2024 22:47:39 +0000
Subject: [PATCH 2/5] Fix for https://github.com/rails/rails/pull/47354

---
 app/helpers/application_helper.rb                           | 2 +-
 config/initializers/30-redmine.rb                           | 2 ++
 .../lib/acts_as_activity_provider.rb                        | 4 ++--
 lib/redmine/pagination.rb                                   | 6 +++---
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 5a0e9b0b4..58189c3e5 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1869,7 +1869,7 @@ module ApplicationHelper
   def render_if_exist(options = {}, locals = {}, &block)
     # Remove test_render_if_exist_should_be_render_partial and test_render_if_exist_should_be_render_nil
     # along with this method in Redmine 7.0
-    ActiveSupport::Deprecation.warn 'ApplicationHelper#render_if_exist is deprecated and will be removed in Redmine 7.0.'
+    Rails.application.deprecators[:redmine].warn 'ApplicationHelper#render_if_exist is deprecated and will be removed in Redmine 7.0.'
 
     if options[:partial]
       if lookup_context.exists?(options[:partial], lookup_context.prefixes, true)
diff --git a/config/initializers/30-redmine.rb b/config/initializers/30-redmine.rb
index 01848a0ef..4eceaf06d 100644
--- a/config/initializers/30-redmine.rb
+++ b/config/initializers/30-redmine.rb
@@ -40,3 +40,5 @@ Rails.application.config.to_prepare do
     Rails.application.config.assets.redmine_extension_paths << paths if paths.present?
   end
 end
+
+Rails.application.deprecators[:redmine] = ActiveSupport::Deprecation.new('7.0', 'Redmine')
diff --git a/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb b/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb
index ac334c19a..6bfc22707 100644
--- a/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb
+++ b/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb
@@ -61,7 +61,7 @@ module Redmine
             elsif scope.respond_to?(:call)
               scope = scope.call
             else
-              ActiveSupport::Deprecation.warn "acts_as_activity_provider with implicit :scope option is deprecated. Please pass a scope on the #{self.name} as a proc."
+              Rails.application.deprecators[:redmine].warn "acts_as_activity_provider with implicit :scope option is deprecated. Please pass a scope on the #{self.name} as a proc."
             end
 
             scope = scope.where("#{provider_options[:timestamp]} >= ?", from) if from
@@ -82,7 +82,7 @@ module Redmine
             elsif respond_to?(:visible)
               scope = scope.visible(user, options)
             else
-              ActiveSupport::Deprecation.warn "acts_as_activity_provider with implicit :permission option is deprecated. Add a visible scope to the #{self.name} model or use explicit :permission option."
+              Rails.application.deprecators[:redmine].warn "acts_as_activity_provider with implicit :permission option is deprecated. Add a visible scope to the #{self.name} model or use explicit :permission option."
               scope = scope.where(Project.allowed_to_condition(user, "view_#{self.name.underscore.pluralize}".to_sym, options))
             end
 
diff --git a/lib/redmine/pagination.rb b/lib/redmine/pagination.rb
index 9857711f5..4ee55165f 100644
--- a/lib/redmine/pagination.rb
+++ b/lib/redmine/pagination.rb
@@ -25,7 +25,7 @@ module Redmine
       def initialize(*args)
         if args.first.is_a?(ActionController::Base)
           args.shift
-          ActiveSupport::Deprecation.warn "Paginator no longer takes a controller instance as the first argument. Remove it from #new arguments."
+          Rails.application.deprecators[:redmine].warn "Paginator no longer takes a controller instance as the first argument. Remove it from #new arguments."
         end
         item_count, per_page, page, page_param = *args
 
@@ -95,12 +95,12 @@ module Redmine
       end
 
       def items_per_page
-        ActiveSupport::Deprecation.warn "Paginator#items_per_page will be removed. Use #per_page instead."
+        Rails.application.deprecators[:redmine].warn "Paginator#items_per_page will be removed. Use #per_page instead."
         per_page
       end
 
       def current
-        ActiveSupport::Deprecation.warn "Paginator#current will be removed. Use .offset instead of .current.offset."
+        Rails.application.deprecators[:redmine].warn "Paginator#current will be removed. Use .offset instead of .current.offset."
         self
       end
     end
-- 
2.39.2

