diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-10-13 10:04:59 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-10-13 10:04:59 +0000 |
commit | 7bea176cdb745aa5351c3836afc89ee339052125 (patch) | |
tree | 1a0e0ea0d56260bd7e26955dcd304eefb46cb0d7 /test/unit/journal_test.rb | |
parent | 60d6e169781e8aa40aab42c5df1f806f646d8bd0 (diff) | |
download | redmine-7bea176cdb745aa5351c3836afc89ee339052125.tar.gz redmine-7bea176cdb745aa5351c3836afc89ee339052125.zip |
Avoid lots of CustomField.find_by_id calls when displaying an issue history with custom fields (#15072).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12217 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/journal_test.rb')
-rw-r--r-- | test/unit/journal_test.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/unit/journal_test.rb b/test/unit/journal_test.rb index e3184bf21..af3a30c9e 100644 --- a/test/unit/journal_test.rb +++ b/test/unit/journal_test.rb @@ -155,6 +155,20 @@ class JournalTest < ActiveSupport::TestCase assert journals.detect {|journal| !journal.issue.project.is_public?} end + def test_preload_journals_details_custom_fields_should_set_custom_field_instance_variable + d = JournalDetail.new(:property => 'cf', :prop_key => '2') + journals = [Journal.new(:details => [d])] + + d.expects(:instance_variable_set).with("@custom_field", CustomField.find(2)).once + Journal.preload_journals_details_custom_fields(journals) + end + + def test_preload_journals_details_custom_fields_with_empty_set + assert_nothing_raised do + Journal.preload_journals_details_custom_fields([]) + end + end + def test_details_should_normalize_dates j = JournalDetail.create!(:old_value => Date.parse('2012-11-03'), :value => Date.parse('2013-01-02')) j.reload @@ -176,6 +190,16 @@ class JournalTest < ActiveSupport::TestCase assert_equal '0', j.value end + def test_custom_field_should_return_custom_field_for_cf_detail + d = JournalDetail.new(:property => 'cf', :prop_key => '2') + assert_equal CustomField.find(2), d.custom_field + end + + def test_custom_field_should_return_nil_for_non_cf_detail + d = JournalDetail.new(:property => 'subject') + assert_equal nil, d.custom_field + end + def test_visible_details_should_include_relations_to_visible_issues_only issue = Issue.generate! visible_issue = Issue.generate! |