]> source.dussan.org Git - redmine.git/commitdiff
Fixed Stack level too deep error when calling #find_name_by_reflection for missing...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 14 Feb 2015 08:57:22 +0000 (08:57 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 14 Feb 2015 08:57:22 +0000 (08:57 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@14002 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/issues_helper.rb
test/unit/helpers/issues_helper_test.rb

index a88adceb9c45a4a1c659def567e545ce2da6205a..3870a066df44b16a2d76d9f762e949dd37a2f28e 100644 (file)
@@ -460,14 +460,14 @@ module IssuesHelper
     end
     @detail_value_name_by_reflection ||= Hash.new do |hash, key|
       association = Issue.reflect_on_association(key.first.to_sym)
+      name = nil
       if association
         record = association.klass.find_by_id(key.last)
         if record
-          record.name.force_encoding('UTF-8')
-          hash[key] = record.name
+          name = record.name.force_encoding('UTF-8')
         end
       end
-      hash[key] ||= nil
+      hash[key] = name
     end
     @detail_value_name_by_reflection[[field, id]]
   end
index 2062464fd2502e5df11c4d9ab832f6dc743a09a9..b275e75db8db22f1f57dfb09a04901acc3b34fdd 100644 (file)
@@ -295,4 +295,8 @@ class IssuesHelperTest < ActionView::TestCase
     assert_equal "Precedes deleted (Issue ##{issue.id})", show_detail(detail, true)
     assert_equal "<strong>Precedes</strong> deleted (<i>Issue ##{issue.id}</i>)", show_detail(detail, false)
   end
+
+  def test_find_name_by_reflection_should_return_nil_for_missing_record
+    assert_nil find_name_by_reflection('status', 99)
+  end
 end