]> source.dussan.org Git - redmine.git/commitdiff
Unable to retrieve custom fields set as "For all projects" via Projects API (#38668).
authorGo MAEDA <maeda@farend.jp>
Fri, 30 Jun 2023 09:20:09 +0000 (09:20 +0000)
committerGo MAEDA <maeda@farend.jp>
Fri, 30 Jun 2023 09:20:09 +0000 (09:20 +0000)
Patch by Hirokazu Onozato.

git-svn-id: https://svn.redmine.org/redmine/trunk@22270 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/projects_helper.rb
test/integration/api_test/projects_test.rb

index 6a995fe6360d823c60f214265ad86918153a570d..d4f7339a0572243cd0f47c420fe62fc7b6b8805d 100644 (file)
@@ -167,7 +167,7 @@ module ProjectsHelper
     end if include_in_api_response?('enabled_modules')
 
     api.array :issue_custom_fields do
-      project.issue_custom_fields.each do |custom_field|
+      project.all_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')
index f0c1973cb1906a4334e6662af895dd3b84777335..c32f7679bbc178017cf15e2ecc4931a187d41ca5 100644 (file)
@@ -86,11 +86,16 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
   end
 
   test "GET /projects.xml with include=issue_custom_fields should return custom fields" do
+    IssueCustomField.find(6).update_attribute :is_for_all, true
+    IssueCustomField.find(8).update_attribute :is_for_all, false
     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"]'
+    # Custom field for all projects
+    assert_select 'issue_custom_fields[type=array] custom_field[id="6"]'
+    assert_select 'issue_custom_fields[type=array] custom_field[id="8"]', 0
   end
 
   test "GET /projects/:id.xml should return the project" do