]> source.dussan.org Git - redmine.git/commitdiff
Tests for #22754.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 4 Jun 2016 07:41:05 +0000 (07:41 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 4 Jun 2016 07:41:05 +0000 (07:41 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@15443 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/integration/api_test/custom_fields_attribute_test.rb

index 7fbfc19e1efc72e68389b823bf9b1ee4c20ecdbe..401b065067dc2f96e1894f229c39ab3fc366b306 100644 (file)
@@ -40,6 +40,26 @@ class Redmine::ApiTest::CustomFieldsAttributeTest < Redmine::ApiTest::Base
     assert_equal "52", group.custom_field_value(field)
   end
 
+  def test_boolean_custom_fields_should_accept_strings
+    field = GroupCustomField.generate!(:field_format => 'bool')
+
+    post '/groups.json', %({"group":{"name":"Foo","custom_field_values":{"#{field.id}": "1"}}}),
+      {'CONTENT_TYPE' => 'application/json'}.merge(credentials('admin'))
+    assert_response :created
+    group = Group.order('id DESC').first
+    assert_equal "1", group.custom_field_value(field)
+  end
+
+  def test_boolean_custom_fields_should_accept_integers
+    field = GroupCustomField.generate!(:field_format => 'bool')
+
+    post '/groups.json', %({"group":{"name":"Foo","custom_field_values":{"#{field.id}": 1}}}),
+      {'CONTENT_TYPE' => 'application/json'}.merge(credentials('admin'))
+    assert_response :created
+    group = Group.order('id DESC').first
+    assert_equal "1", group.custom_field_value(field)
+  end
+
   def test_multivalued_custom_fields_should_accept_an_array
     field = GroupCustomField.generate!(
       :field_format => 'list',