##// END OF EJS Templates
Fixed: error when serializing back objects with custom fields using ActiveResource (#6403)....
Jean-Philippe Lang -
r4366:0e19aa4362a0
parent child
Show More
@@ -104,4 +104,15 module CustomFieldsHelper
104 def custom_field_formats_for_select
104 def custom_field_formats_for_select
105 Redmine::CustomFieldFormat.as_select
105 Redmine::CustomFieldFormat.as_select
106 end
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 end
118 end
@@ -19,11 +19,7 api.array :issues do
19 api.done_ratio issue.done_ratio
19 api.done_ratio issue.done_ratio
20 api.estimated_hours issue.estimated_hours
20 api.estimated_hours issue.estimated_hours
21
21
22 api.array :custom_fields do
22 render_api_custom_values issue.custom_field_values, api
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
27
23
28 api.created_on issue.created_on
24 api.created_on issue.created_on
29 api.updated_on issue.updated_on
25 api.updated_on issue.updated_on
@@ -20,11 +20,7 api.issue do
20 api.spent_hours @issue.spent_hours
20 api.spent_hours @issue.spent_hours
21 end
21 end
22
22
23 api.array :custom_fields do
23 render_api_custom_values @issue.custom_field_values, api
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?
28
24
29 api.created_on @issue.created_on
25 api.created_on @issue.created_on
30 api.updated_on @issue.updated_on
26 api.updated_on @issue.updated_on
@@ -6,11 +6,9 api.array :projects do
6 api.identifier project.identifier
6 api.identifier project.identifier
7 api.description project.description
7 api.description project.description
8 api.parent(:id => project.parent_id, :name => project.parent.name) unless project.parent.nil?
8 api.parent(:id => project.parent_id, :name => project.parent.name) unless project.parent.nil?
9 api.array :custom_fields do
9
10 project.visible_custom_field_values.each do |custom_value|
10 render_api_custom_values project.visible_custom_field_values, api
11 api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
11
12 end
13 end unless project.custom_field_values.empty?
14 api.created_on project.created_on
12 api.created_on project.created_on
15 api.updated_on project.updated_on
13 api.updated_on project.updated_on
16 end
14 end
@@ -5,11 +5,7 api.project do
5 api.description @project.description
5 api.description @project.description
6 api.homepage @project.homepage
6 api.homepage @project.homepage
7
7
8 api.array :custom_fields do
8 render_api_custom_values @project.visible_custom_field_values, api
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?
13
9
14 api.created_on @project.created_on
10 api.created_on @project.created_on
15 api.updated_on @project.updated_on
11 api.updated_on @project.updated_on
@@ -9,11 +9,7 api.array :users do
9 api.created_on user.created_on
9 api.created_on user.created_on
10 api.last_login_on user.last_login_on
10 api.last_login_on user.last_login_on
11
11
12 api.array :custom_fields do
12 render_api_custom_values user.visible_custom_field_values, api
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?
17 end
13 end
18 end
14 end
19 end
15 end
@@ -7,11 +7,7 api.user do
7 api.created_on @user.created_on
7 api.created_on @user.created_on
8 api.last_login_on @user.last_login_on
8 api.last_login_on @user.last_login_on
9
9
10 api.array :custom_fields do
10 render_api_custom_values @user.visible_custom_field_values, api
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?
15
11
16 api.array :memberships do
12 api.array :memberships do
17 @memberships.each do |membership|
13 @memberships.each do |membership|
@@ -91,6 +91,32 class ApiTest::IssuesTest < ActionController::IntegrationTest
91 end
91 end
92
92
93 context "GET /issues/:id" do
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 context "with subtasks" do
120 context "with subtasks" do
95 setup do
121 setup do
96 @c1 = Issue.generate!(:status_id => 1, :subject => "child c1", :tracker_id => 1, :project_id => 1, :parent_issue_id => 1)
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