Project

General

Profile

Defect #39527 » 39527.patch

Go MAEDA, 2023-11-12 13:21

View differences:

app/helpers/application_helper.rb
1837 1837
  end
1838 1838

  
1839 1839
  def render_if_exist(options = {}, locals = {}, &block)
1840
    # Remove test_redner_if_exist_should_be_render_partial and test_redner_if_exist_should_be_render_nil
1841
    # along with this method in Redmine 7.0
1842
    ActiveSupport::Deprecation.warn 'ApplicationHelper#render_if_exist is deprecated and will be removed in Redmine 7.0.'
1843

  
1840 1844
    if options[:partial]
1841 1845
      if lookup_context.exists?(options[:partial], lookup_context.prefixes, true)
1842 1846
        render(options, locals, &block)
test/helpers/application_helper_test.rb
2186 2186
    assert_match(/name="new_issue-[a-z0-9]{8}"/, labelled_form_for(Issue.new){})
2187 2187
  end
2188 2188

  
2189
  # TODO: Remove this test when ApplicationHelper#render_if_exist is removed
2189 2190
  def test_redner_if_exist_should_be_render_partial
2191
    saved_behavior = ActiveSupport::Deprecation.behavior
2192
    ActiveSupport::Deprecation.behavior = :silence
2193

  
2190 2194
    controller.prepend_view_path "test/fixtures/views"
2191 2195
    assert_equal "partial html\n", render_if_exist(:partial => 'partial')
2196
  ensure
2197
    ActiveSupport::Deprecation.behavior = saved_behavior
2192 2198
  end
2193 2199

  
2200
  # TODO: Remove this test when ApplicationHelper#render_if_exist is removed
2194 2201
  def test_redner_if_exist_should_be_render_nil
2202
    saved_behavior = ActiveSupport::Deprecation.behavior
2203
    ActiveSupport::Deprecation.behavior = :silence
2204

  
2195 2205
    controller.prepend_view_path "test/fixtures/views"
2196 2206
    assert_nil render_if_exist(:partial => 'non_exist_partial')
2207
  ensure
2208
    ActiveSupport::Deprecation.behavior = saved_behavior
2197 2209
  end
2198 2210

  
2199 2211
  def test_export_csv_encoding_select_tag_should_return_nil_when_general_csv_encoding_is_UTF8
(1-1/2)