@@ -104,4 +104,15 module CustomFieldsHelper | |||
|
104 | 104 | def custom_field_formats_for_select |
|
105 | 105 | Redmine::CustomFieldFormat.as_select |
|
106 | 106 | end |
|
107 | ||
|
108 | # Renders the custom_values in api views | |
|
109 | def render_api_custom_values(custom_values, api) | |
|
110 | api.array :custom_fields do | |
|
111 | custom_values.each do |custom_value| | |
|
112 | api.custom_field :id => custom_value.custom_field_id, :name => custom_value.custom_field.name do | |
|
113 | api.value custom_value.value | |
|
114 | end | |
|
115 | end | |
|
116 | end unless custom_values.empty? | |
|
117 | end | |
|
107 | 118 | end |
@@ -19,11 +19,7 api.array :issues do | |||
|
19 | 19 | api.done_ratio issue.done_ratio |
|
20 | 20 | api.estimated_hours issue.estimated_hours |
|
21 | 21 | |
|
22 | api.array :custom_fields do | |
|
23 | issue.custom_field_values.each do |custom_value| | |
|
24 | api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name | |
|
25 | end | |
|
26 | end | |
|
22 | render_api_custom_values issue.custom_field_values, api | |
|
27 | 23 | |
|
28 | 24 | api.created_on issue.created_on |
|
29 | 25 | api.updated_on issue.updated_on |
@@ -20,11 +20,7 api.issue do | |||
|
20 | 20 | api.spent_hours @issue.spent_hours |
|
21 | 21 | end |
|
22 | 22 | |
|
23 | api.array :custom_fields do | |
|
24 | @issue.custom_field_values.each do |custom_value| | |
|
25 | api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name | |
|
26 | end | |
|
27 | end unless @issue.custom_field_values.empty? | |
|
23 | render_api_custom_values @issue.custom_field_values, api | |
|
28 | 24 | |
|
29 | 25 | api.created_on @issue.created_on |
|
30 | 26 | api.updated_on @issue.updated_on |
@@ -6,11 +6,9 api.array :projects do | |||
|
6 | 6 | api.identifier project.identifier |
|
7 | 7 | api.description project.description |
|
8 | 8 | api.parent(:id => project.parent_id, :name => project.parent.name) unless project.parent.nil? |
|
9 | api.array :custom_fields do | |
|
10 |
|
|
|
11 | api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name | |
|
12 | end | |
|
13 | end unless project.custom_field_values.empty? | |
|
9 | ||
|
10 | render_api_custom_values project.visible_custom_field_values, api | |
|
11 | ||
|
14 | 12 | api.created_on project.created_on |
|
15 | 13 | api.updated_on project.updated_on |
|
16 | 14 | end |
@@ -5,11 +5,7 api.project do | |||
|
5 | 5 | api.description @project.description |
|
6 | 6 | api.homepage @project.homepage |
|
7 | 7 | |
|
8 | api.array :custom_fields do | |
|
9 | @project.visible_custom_field_values.each do |custom_value| | |
|
10 | api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name | |
|
11 | end | |
|
12 | end unless @project.custom_field_values.empty? | |
|
8 | render_api_custom_values @project.visible_custom_field_values, api | |
|
13 | 9 | |
|
14 | 10 | api.created_on @project.created_on |
|
15 | 11 | api.updated_on @project.updated_on |
@@ -9,11 +9,7 api.array :users do | |||
|
9 | 9 | api.created_on user.created_on |
|
10 | 10 | api.last_login_on user.last_login_on |
|
11 | 11 | |
|
12 | api.array :custom_fields do | |
|
13 | user.visible_custom_field_values.each do |custom_value| | |
|
14 | api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name | |
|
15 | end | |
|
16 | end unless user.visible_custom_field_values.empty? | |
|
12 | render_api_custom_values user.visible_custom_field_values, api | |
|
17 | 13 | end |
|
18 | 14 | end |
|
19 | 15 | end |
@@ -7,11 +7,7 api.user do | |||
|
7 | 7 | api.created_on @user.created_on |
|
8 | 8 | api.last_login_on @user.last_login_on |
|
9 | 9 | |
|
10 | api.array :custom_fields do | |
|
11 | @user.visible_custom_field_values.each do |custom_value| | |
|
12 | api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name | |
|
13 | end | |
|
14 | end unless @user.visible_custom_field_values.empty? | |
|
10 | render_api_custom_values @user.visible_custom_field_values, api | |
|
15 | 11 | |
|
16 | 12 | api.array :memberships do |
|
17 | 13 | @memberships.each do |membership| |
@@ -91,6 +91,32 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
91 | 91 | end |
|
92 | 92 | |
|
93 | 93 | context "GET /issues/:id" do |
|
94 | context "with custom fields" do | |
|
95 | context ".xml" do | |
|
96 | should "display custom fields" do | |
|
97 | get '/issues/3.xml' | |
|
98 | ||
|
99 | assert_tag :tag => 'issue', | |
|
100 | :child => { | |
|
101 | :tag => 'custom_fields', | |
|
102 | :attributes => { :type => 'array' }, | |
|
103 | :child => { | |
|
104 | :tag => 'custom_field', | |
|
105 | :attributes => { :id => '1'}, | |
|
106 | :child => { | |
|
107 | :tag => 'value', | |
|
108 | :content => 'MySQL' | |
|
109 | } | |
|
110 | } | |
|
111 | } | |
|
112 | ||
|
113 | assert_nothing_raised do | |
|
114 | Hash.from_xml(response.body).to_xml | |
|
115 | end | |
|
116 | end | |
|
117 | end | |
|
118 | end | |
|
119 | ||
|
94 | 120 | context "with subtasks" do |
|
95 | 121 | setup do |
|
96 | 122 | @c1 = Issue.generate!(:status_id => 1, :subject => "child c1", :tracker_id => 1, :project_id => 1, :parent_issue_id => 1) |
General Comments 0
You need to be logged in to leave comments.
Login now