]> source.dussan.org Git - redmine.git/commitdiff
REST API with JSON content missing false values (#20788).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 28 Nov 2018 18:03:07 +0000 (18:03 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 28 Nov 2018 18:03:07 +0000 (18:03 +0000)
Patch by Yuichi HARADA.

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

lib/redmine/views/builders/structure.rb
test/unit/lib/redmine/views/builders/json_test.rb

index 3f4468b8e05312a1193d95c2046638a15926fa9c..a473d4d58c8f10b66b3e7fe64bb5c28b9cf8ad6d 100644 (file)
@@ -47,7 +47,7 @@ module Redmine
         end
 
         def method_missing(sym, *args, &block)
-          if args.any?
+          if args.count > 0
             if args.first.is_a?(Hash)
               if @struct.last.is_a?(Array)
                 @struct.last << args.first unless block
index 8ffb71fa7f70298607bcf501acfb35d0515fc0a9..b29fe1a65bc59b03948b4a7ac62b1c784e81db5e 100644 (file)
 require File.expand_path('../../../../../../test_helper', __FILE__)
 
 class Redmine::Views::Builders::JsonTest < ActiveSupport::TestCase
+  def test_nil_and_false
+    assert_json_output({'value' => nil}) do |b|
+      b.value nil
+    end
+
+    assert_json_output({'value' => false}) do |b|
+      b.value false
+    end
+  end
 
   def test_hash
     assert_json_output({'person' => {'name' => 'Ryan', 'age' => 32}}) do |b|