Browse Source

Adds a test for setting multivalued custom fields with JSON (#19368).

git-svn-id: http://svn.redmine.org/redmine/trunk@14084 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/3.1.0
Jean-Philippe Lang 9 years ago
parent
commit
9dfe8fe03c
1 changed files with 21 additions and 0 deletions
  1. 21
    0
      test/integration/api_test/custom_fields_attribute_test.rb

+ 21
- 0
test/integration/api_test/custom_fields_attribute_test.rb View File

@@ -39,4 +39,25 @@ class Redmine::ApiTest::CustomFieldsAttributeTest < Redmine::ApiTest::Base
group = Group.order('id DESC').first
assert_equal "52", group.custom_field_value(field)
end

def test_multivalued_custom_fields_should_accept_an_array
field = GroupCustomField.generate!(
:field_format => 'list',
:multiple => true,
:possible_values => ["V1", "V2", "V3"],
:default_value => "V2"
)

payload = <<-JSON
{"group": {"name":"Foooo",
"custom_field_values":{"#{field.id}":["V1","V3"]}
}
}
JSON

post '/groups.json', payload, {'CONTENT_TYPE' => 'application/json'}.merge(credentials('admin'))
assert_response :created
group = Group.order('id DESC').first
assert_equal ["V1", "V3"], group.custom_field_value(field)
end
end

Loading…
Cancel
Save