def custom_field_formats_for_select
Redmine::CustomFieldFormat.as_select
end
+
+ # Renders the custom_values in api views
+ def render_api_custom_values(custom_values, api)
+ api.array :custom_fields do
+ custom_values.each do |custom_value|
+ api.custom_field :id => custom_value.custom_field_id, :name => custom_value.custom_field.name do
+ api.value custom_value.value
+ end
+ end
+ end unless custom_values.empty?
+ end
end
api.done_ratio issue.done_ratio
api.estimated_hours issue.estimated_hours
- api.array :custom_fields do
- issue.custom_field_values.each do |custom_value|
- api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
- end
- end
+ render_api_custom_values issue.custom_field_values, api
api.created_on issue.created_on
api.updated_on issue.updated_on
api.spent_hours @issue.spent_hours
end
- api.array :custom_fields do
- @issue.custom_field_values.each do |custom_value|
- api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
- end
- end unless @issue.custom_field_values.empty?
+ render_api_custom_values @issue.custom_field_values, api
api.created_on @issue.created_on
api.updated_on @issue.updated_on
api.identifier project.identifier
api.description project.description
api.parent(:id => project.parent_id, :name => project.parent.name) unless project.parent.nil?
- api.array :custom_fields do
- project.visible_custom_field_values.each do |custom_value|
- api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
- end
- end unless project.custom_field_values.empty?
+
+ render_api_custom_values project.visible_custom_field_values, api
+
api.created_on project.created_on
api.updated_on project.updated_on
end
api.description @project.description
api.homepage @project.homepage
- api.array :custom_fields do
- @project.visible_custom_field_values.each do |custom_value|
- api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
- end
- end unless @project.custom_field_values.empty?
+ render_api_custom_values @project.visible_custom_field_values, api
api.created_on @project.created_on
api.updated_on @project.updated_on
api.created_on user.created_on
api.last_login_on user.last_login_on
- api.array :custom_fields do
- user.visible_custom_field_values.each do |custom_value|
- api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
- end
- end unless user.visible_custom_field_values.empty?
+ render_api_custom_values user.visible_custom_field_values, api
end
end
end
api.created_on @user.created_on
api.last_login_on @user.last_login_on
- api.array :custom_fields do
- @user.visible_custom_field_values.each do |custom_value|
- api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
- end
- end unless @user.visible_custom_field_values.empty?
+ render_api_custom_values @user.visible_custom_field_values, api
api.array :memberships do
@memberships.each do |membership|
end
context "GET /issues/:id" do
+ context "with custom fields" do
+ context ".xml" do
+ should "display custom fields" do
+ get '/issues/3.xml'
+
+ assert_tag :tag => 'issue',
+ :child => {
+ :tag => 'custom_fields',
+ :attributes => { :type => 'array' },
+ :child => {
+ :tag => 'custom_field',
+ :attributes => { :id => '1'},
+ :child => {
+ :tag => 'value',
+ :content => 'MySQL'
+ }
+ }
+ }
+
+ assert_nothing_raised do
+ Hash.from_xml(response.body).to_xml
+ end
+ end
+ end
+ end
+
context "with subtasks" do
setup do
@c1 = Issue.generate!(:status_id => 1, :subject => "child c1", :tracker_id => 1, :project_id => 1, :parent_issue_id => 1)