diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-10-31 09:17:29 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-10-31 09:17:29 +0000 |
commit | e6112a9710cbe33a0ee5787c14498a55ce9ba891 (patch) | |
tree | caa6adf8972bac64745faf5036379bfeb505b56e /test | |
parent | 9a3b8e0b1eaa6239297f53a5f1977457c28723e1 (diff) | |
download | redmine-e6112a9710cbe33a0ee5787c14498a55ce9ba891.tar.gz redmine-e6112a9710cbe33a0ee5787c14498a55ce9ba891.zip |
New custom fields of existing issues are not initialized with their default value (#21074).
git-svn-id: http://svn.redmine.org/redmine/trunk@14773 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/integration/api_test/issues_test.rb | 4 | ||||
-rw-r--r-- | test/unit/custom_value_test.rb | 20 |
2 files changed, 17 insertions, 7 deletions
diff --git a/test/integration/api_test/issues_test.rb b/test/integration/api_test/issues_test.rb index 18dbfaad9..5a7d64d47 100644 --- a/test/integration/api_test/issues_test.rb +++ b/test/integration/api_test/issues_test.rb @@ -562,7 +562,7 @@ JSON assert_equal "", issue.reload.custom_field_value(field) end - test "PUT /issues/:id.json with tracker change and omitted custom field specific to that tracker does not set default value" do + test "PUT /issues/:id.json with tracker change and omitted custom field specific to that tracker should set default value" do field = IssueCustomField.generate!(:default_value => "Default", :tracker_ids => [2]) issue = Issue.generate!(:project_id => 1, :tracker_id => 1) @@ -573,7 +573,7 @@ JSON end assert_equal 2, issue.reload.tracker_id - assert_nil issue.reload.custom_field_value(field) + assert_equal "Default", issue.reload.custom_field_value(field) end test "PUT /issues/:id.json with tracker change and custom field specific to that tracker set to blank should not set default value" do diff --git a/test/unit/custom_value_test.rb b/test/unit/custom_value_test.rb index b344994a4..954c3aee9 100644 --- a/test/unit/custom_value_test.rb +++ b/test/unit/custom_value_test.rb @@ -20,15 +20,25 @@ require File.expand_path('../../test_helper', __FILE__) class CustomValueTest < ActiveSupport::TestCase fixtures :custom_fields, :custom_values, :users - def test_default_value - field = CustomField.find_by_default_value('Default string') - assert_not_nil field + def test_new_without_value_should_set_default_value + field = CustomField.generate!(:default_value => 'Default string') v = CustomValue.new(:custom_field => field) assert_equal 'Default string', v.value + end + + def test_new_with_value_should_not_set_default_value + field = CustomField.generate!(:default_value => 'Default string') + + v = CustomValue.new(:custom_field => field, :value => 'String') + assert_equal 'String', v.value + end + + def test_new_with_nil_value_should_not_set_default_value + field = CustomField.generate!(:default_value => 'Default string') - v = CustomValue.new(:custom_field => field, :value => 'Not empty') - assert_equal 'Not empty', v.value + v = CustomValue.new(:custom_field => field, :value => nil) + assert_nil v.value end def test_sti_polymorphic_association |