]> source.dussan.org Git - redmine.git/commitdiff
Deprecate unused ApplicationHelper#render_if_exist (#39527).
authorGo MAEDA <maeda@farend.jp>
Sun, 19 Nov 2023 07:41:21 +0000 (07:41 +0000)
committerGo MAEDA <maeda@farend.jp>
Sun, 19 Nov 2023 07:41:21 +0000 (07:41 +0000)
git-svn-id: https://svn.redmine.org/redmine/trunk@22466 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
test/helpers/application_helper_test.rb

index a1d989e250d7901f5795144154beb5de5ef6bb50..4c130e2fa3661e91d9d7b1edcfb44adfa51f58ed 100644 (file)
@@ -1837,6 +1837,10 @@ module ApplicationHelper
   end
 
   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.'
+
     if options[:partial]
       if lookup_context.exists?(options[:partial], lookup_context.prefixes, true)
         render(options, locals, &block)
index a46e6c22ab2a9ec01a78b5b5b6bb95c7c69dcb7c..7387487f2661f1dec861fe64df2e2d70b1b393cb 100644 (file)
@@ -2186,14 +2186,26 @@ class ApplicationHelperTest < Redmine::HelperTest
     assert_match(/name="new_issue-[a-z0-9]{8}"/, labelled_form_for(Issue.new){})
   end
 
+  # TODO: Remove this test when ApplicationHelper#render_if_exist is removed
   def test_render_if_exist_should_be_render_partial
+    saved_behavior = ActiveSupport::Deprecation.behavior
+    ActiveSupport::Deprecation.behavior = :silence
+
     controller.prepend_view_path "test/fixtures/views"
     assert_equal "partial html\n", render_if_exist(:partial => 'partial')
+  ensure
+    ActiveSupport::Deprecation.behavior = saved_behavior
   end
 
+  # TODO: Remove this test when ApplicationHelper#render_if_exist is removed
   def test_render_if_exist_should_be_render_nil
+    saved_behavior = ActiveSupport::Deprecation.behavior
+    ActiveSupport::Deprecation.behavior = :silence
+
     controller.prepend_view_path "test/fixtures/views"
     assert_nil render_if_exist(:partial => 'non_exist_partial')
+  ensure
+    ActiveSupport::Deprecation.behavior = saved_behavior
   end
 
   def test_export_csv_encoding_select_tag_should_return_nil_when_general_csv_encoding_is_UTF8