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