##// END OF EJS Templates
Fixed assertion (#19368)....
Jean-Philippe Lang -
r13704:1014ba195f40
parent child
Show More
@@ -1,63 +1,63
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2015 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../../test_helper', __FILE__)
19 19
20 20 class Redmine::ApiTest::CustomFieldsAttributeTest < Redmine::ApiTest::Base
21 21 fixtures :users
22 22
23 23 def test_integer_custom_fields_should_accept_strings
24 24 field = GroupCustomField.generate!(:field_format => 'int')
25 25
26 26 post '/groups.json', %({"group":{"name":"Foo","custom_field_values":{"#{field.id}":"52"}}}),
27 27 {'CONTENT_TYPE' => 'application/json'}.merge(credentials('admin'))
28 28 assert_response :created
29 29 group = Group.order('id DESC').first
30 30 assert_equal "52", group.custom_field_value(field)
31 31 end
32 32
33 33 def test_integer_custom_fields_should_accept_integers
34 34 field = GroupCustomField.generate!(:field_format => 'int')
35 35
36 36 post '/groups.json', %({"group":{"name":"Foo","custom_field_values":{"#{field.id}":52}}}),
37 37 {'CONTENT_TYPE' => 'application/json'}.merge(credentials('admin'))
38 38 assert_response :created
39 39 group = Group.order('id DESC').first
40 40 assert_equal "52", group.custom_field_value(field)
41 41 end
42 42
43 43 def test_multivalued_custom_fields_should_accept_an_array
44 44 field = GroupCustomField.generate!(
45 45 :field_format => 'list',
46 46 :multiple => true,
47 47 :possible_values => ["V1", "V2", "V3"],
48 48 :default_value => "V2"
49 49 )
50 50
51 51 payload = <<-JSON
52 52 {"group": {"name":"Foooo",
53 53 "custom_field_values":{"#{field.id}":["V1","V3"]}
54 54 }
55 55 }
56 56 JSON
57 57
58 58 post '/groups.json', payload, {'CONTENT_TYPE' => 'application/json'}.merge(credentials('admin'))
59 59 assert_response :created
60 60 group = Group.order('id DESC').first
61 assert_equal ["V1", "V3"], group.custom_field_value(field)
61 assert_equal ["V1", "V3"], group.custom_field_value(field).sort
62 62 end
63 63 end
General Comments 0
You need to be logged in to leave comments. Login now