@@ -460,14 +460,14 module IssuesHelper | |||||
460 | end |
|
460 | end | |
461 | @detail_value_name_by_reflection ||= Hash.new do |hash, key| |
|
461 | @detail_value_name_by_reflection ||= Hash.new do |hash, key| | |
462 | association = Issue.reflect_on_association(key.first.to_sym) |
|
462 | association = Issue.reflect_on_association(key.first.to_sym) | |
|
463 | name = nil | |||
463 | if association |
|
464 | if association | |
464 | record = association.klass.find_by_id(key.last) |
|
465 | record = association.klass.find_by_id(key.last) | |
465 | if record |
|
466 | if record | |
466 | record.name.force_encoding('UTF-8') |
|
467 | name = record.name.force_encoding('UTF-8') | |
467 | hash[key] = record.name |
|
|||
468 | end |
|
468 | end | |
469 | end |
|
469 | end | |
470 |
hash[key] |
|
470 | hash[key] = name | |
471 | end |
|
471 | end | |
472 | @detail_value_name_by_reflection[[field, id]] |
|
472 | @detail_value_name_by_reflection[[field, id]] | |
473 | end |
|
473 | end |
@@ -295,4 +295,8 class IssuesHelperTest < ActionView::TestCase | |||||
295 | assert_equal "Precedes deleted (Issue ##{issue.id})", show_detail(detail, true) |
|
295 | assert_equal "Precedes deleted (Issue ##{issue.id})", show_detail(detail, true) | |
296 | assert_equal "<strong>Precedes</strong> deleted (<i>Issue ##{issue.id}</i>)", show_detail(detail, false) |
|
296 | assert_equal "<strong>Precedes</strong> deleted (<i>Issue ##{issue.id}</i>)", show_detail(detail, false) | |
297 | end |
|
297 | end | |
|
298 | ||||
|
299 | def test_find_name_by_reflection_should_return_nil_for_missing_record | |||
|
300 | assert_nil find_name_by_reflection('status', 99) | |||
|
301 | end | |||
298 | end |
|
302 | end |
General Comments 0
You need to be logged in to leave comments.
Login now