##// END OF EJS Templates
Missing type=array attributes in custom fields API (#16739)....
Jean-Philippe Lang -
r12834:9fdd0862f74c
parent child
Show More
@@ -1,43 +1,43
1 1 api.array :custom_fields do
2 2 @custom_fields.each do |field|
3 3 api.custom_field do
4 4 api.id field.id
5 5 api.name field.name
6 6 api.customized_type field.class.customized_class.name.underscore if field.class.customized_class
7 7 api.field_format field.field_format
8 8 api.regexp field.regexp
9 9 api.min_length field.min_length
10 10 api.max_length field.max_length
11 11 api.is_required field.is_required?
12 12 api.is_filter field.is_filter?
13 13 api.searchable field.searchable
14 14 api.multiple field.multiple?
15 15 api.default_value field.default_value
16 16 api.visible field.visible?
17 17
18 18 values = field.possible_values_options
19 19 if values.present?
20 20 api.array :possible_values do
21 21 values.each do |label, value|
22 22 api.possible_value do
23 23 api.value value || label
24 24 end
25 25 end
26 26 end
27 27 end
28 28
29 29 if field.is_a?(IssueCustomField)
30 api.trackers do
30 api.array :trackers do
31 31 field.trackers.each do |tracker|
32 32 api.tracker :id => tracker.id, :name => tracker.name
33 33 end
34 34 end
35 api.roles do
35 api.array :roles do
36 36 field.roles.each do |role|
37 37 api.role :id => role.id, :name => role.name
38 38 end
39 39 end
40 40 end
41 41 end
42 42 end
43 43 end
@@ -1,43 +1,45
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2014 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::CustomFieldsTest < Redmine::ApiTest::Base
21 21 fixtures :users, :custom_fields
22 22
23 23 def setup
24 24 Setting.rest_api_enabled = '1'
25 25 end
26 26
27 27 test "GET /custom_fields.xml should return custom fields" do
28 28 get '/custom_fields.xml', {}, credentials('admin')
29 29 assert_response :success
30 30 assert_equal 'application/xml', response.content_type
31 31
32 32 assert_select 'custom_fields' do
33 33 assert_select 'custom_field' do
34 34 assert_select 'name', :text => 'Database'
35 35 assert_select 'id', :text => '2'
36 36 assert_select 'customized_type', :text => 'issue'
37 37 assert_select 'possible_values[type=array]' do
38 38 assert_select 'possible_value>value', :text => 'PostgreSQL'
39 39 end
40 assert_select 'trackers[type=array]'
41 assert_select 'roles[type=array]'
40 42 end
41 43 end
42 44 end
43 45 end
General Comments 0
You need to be logged in to leave comments. Login now