From 558a951ed64a3639ac08fdc7245dffab8607ab3f Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 4 Dec 2010 10:41:31 +0000 Subject: [PATCH] Fixes unhandled case in json builder. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4463 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/views/builders/structure.rb | 6 +++++- test/unit/lib/redmine/views/builders/json_test.rb | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/redmine/views/builders/structure.rb b/lib/redmine/views/builders/structure.rb index c168bd73a..9b9481587 100644 --- a/lib/redmine/views/builders/structure.rb +++ b/lib/redmine/views/builders/structure.rb @@ -56,7 +56,11 @@ module Redmine if @struct.last.is_a?(Array) @struct.last << ret else - @struct.last[sym] = ret + if @struct.last.has_key?(sym) && @struct.last[sym].is_a?(Hash) + @struct.last[sym].merge! ret + else + @struct.last[sym] = ret + end end end end diff --git a/test/unit/lib/redmine/views/builders/json_test.rb b/test/unit/lib/redmine/views/builders/json_test.rb index 195fba020..919fe2236 100644 --- a/test/unit/lib/redmine/views/builders/json_test.rb +++ b/test/unit/lib/redmine/views/builders/json_test.rb @@ -35,6 +35,13 @@ class Redmine::Views::Builders::JsonTest < HelperTestCase b.birth :city => 'London', :country => 'UK' end end + + assert_json_output({'person' => {'id' => 1, 'name' => 'Ryan', 'birth' => {'city' => 'London', 'country' => 'UK'}}}) do |b| + b.person :id => 1 do + b.name 'Ryan' + b.birth :city => 'London', :country => 'UK' + end + end end def test_array -- 2.39.5