From cf588edbeab9209bfa751a18af6a1f1321fc66a7 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Thu, 29 Nov 2018 15:41:34 +0000 Subject: [PATCH] Merged r17643 to 3.3-stable (#20788). git-svn-id: http://svn.redmine.org/redmine/branches/3.3-stable@17651 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/views/builders/structure.rb | 2 +- test/unit/lib/redmine/views/builders/json_test.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/redmine/views/builders/structure.rb b/lib/redmine/views/builders/structure.rb index 03f73c649..420190fc9 100644 --- a/lib/redmine/views/builders/structure.rb +++ b/lib/redmine/views/builders/structure.rb @@ -48,7 +48,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 diff --git a/test/unit/lib/redmine/views/builders/json_test.rb b/test/unit/lib/redmine/views/builders/json_test.rb index 0cb75c98b..13381e3aa 100644 --- a/test/unit/lib/redmine/views/builders/json_test.rb +++ b/test/unit/lib/redmine/views/builders/json_test.rb @@ -18,6 +18,15 @@ 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| -- 2.39.5