]> source.dussan.org Git - redmine.git/commitdiff
Include value and label of possible values in custom fields API (#22745).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 8 May 2016 08:44:53 +0000 (08:44 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 8 May 2016 08:44:53 +0000 (08:44 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@15401 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/views/custom_fields/index.api.rsb
test/integration/api_test/custom_fields_test.rb

index 77c9cf3b36a32f88723fda8431c33ae978e0eede..8233ed1403273fc56f9e86ecb980266b50d4209f 100644 (file)
@@ -21,6 +21,7 @@ api.array :custom_fields do
           values.each do |label, value|
             api.possible_value do
               api.value value || label
+              api.label label
             end
           end
         end
index 54f8b8966aa4a7bf7657f1d2a881711dda972a0d..c3efa6b9be13c248ace110b81b590ae2e9a8cd14 100644 (file)
@@ -32,10 +32,25 @@ class Redmine::ApiTest::CustomFieldsTest < Redmine::ApiTest::Base
         assert_select 'customized_type', :text => 'issue'
         assert_select 'possible_values[type=array]' do
           assert_select 'possible_value>value', :text => 'PostgreSQL'
+          assert_select 'possible_value>label', :text => 'PostgreSQL'
         end
         assert_select 'trackers[type=array]'
         assert_select 'roles[type=array]'
       end
     end
   end
+
+  test "GET /custom_fields.xml should include value and label for enumeration custom fields" do
+    field = IssueCustomField.generate!(:field_format => 'enumeration')
+    foo = field.enumerations.create!(:name => 'Foo')
+    bar = field.enumerations.create!(:name => 'Bar')
+
+    get '/custom_fields.xml', {}, credentials('admin')
+    assert_response :success
+
+    assert_select 'possible_value' do
+      assert_select "value:contains(?) + label:contains(?)", foo.id.to_s, 'Foo'
+      assert_select "value:contains(?) + label:contains(?)", bar.id.to_s, 'Bar'
+    end
+  end
 end