From 49a2006681dfd19a15b03eadd54be784b393c6d0 Mon Sep 17 00:00:00 2001 From: Jens Kraemer Date: Fri, 17 Apr 2020 12:38:52 +0800 Subject: [PATCH] adds option to include issue custom fields in projects#show API response --- app/helpers/projects_helper.rb | 6 ++++++ test/integration/api_test/projects_test.rb | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 0df19d56d..785f84291 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -152,6 +152,12 @@ module ProjectsHelper api.enabled_module(:id => enabled_module.id, :name => enabled_module.name) end end if include_in_api_response?('enabled_modules') + + api.array :issue_custom_fields do + project.issue_custom_fields.each do |custom_field| + api.custom_field(:id => custom_field.id, :name => custom_field.name) + end + end if include_in_api_response?('issue_custom_fields') end def bookmark_link(project, user = User.current) diff --git a/test/integration/api_test/projects_test.rb b/test/integration/api_test/projects_test.rb index 2e4e73c3a..341865211 100644 --- a/test/integration/api_test/projects_test.rb +++ b/test/integration/api_test/projects_test.rb @@ -83,6 +83,14 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base assert_select 'enabled_modules[type=array] enabled_module[name=issue_tracking]' end + test "GET /projects.xml with include=issue_custom_fields should return custom fields" do + get '/projects.xml?include=issue_custom_fields' + assert_response :success + assert_equal 'application/xml', @response.media_type + + assert_select 'issue_custom_fields[type=array] custom_field[name="Project 1 cf"]' + end + test "GET /projects/:id.xml should return the project" do Project.find(1).update!(:inherit_members => '1') -- 2.20.1