@@ -36,7 +36,7 module Redmine | |||
|
36 | 36 | if args.any? |
|
37 | 37 | if args.first.is_a?(Hash) |
|
38 | 38 | if @struct.last.is_a?(Array) |
|
39 | @struct.last << args.first | |
|
39 | @struct.last << args.first unless block | |
|
40 | 40 | else |
|
41 | 41 | @struct.last[sym] = args.first |
|
42 | 42 | end |
@@ -50,7 +50,7 module Redmine | |||
|
50 | 50 | end |
|
51 | 51 | |
|
52 | 52 | if block |
|
53 | @struct << {} | |
|
53 | @struct << (args.first.is_a?(Hash) ? args.first : {}) | |
|
54 | 54 | block.call(self) |
|
55 | 55 | ret = @struct.pop |
|
56 | 56 | if @struct.last.is_a?(Array) |
@@ -51,6 +51,17 class Redmine::Views::Builders::JsonTest < HelperTestCase | |||
|
51 | 51 | b.book :title => 'Book 2', :author => 'G. Cooper' |
|
52 | 52 | end |
|
53 | 53 | end |
|
54 | ||
|
55 | assert_json_output({'books' => [{'title' => 'Book 1', 'author' => 'B. Smith'}, {'title' => 'Book 2', 'author' => 'G. Cooper'}]}) do |b| | |
|
56 | b.array :books do |b| | |
|
57 | b.book :title => 'Book 1' do | |
|
58 | b.author 'B. Smith' | |
|
59 | end | |
|
60 | b.book :title => 'Book 2' do | |
|
61 | b.author 'G. Cooper' | |
|
62 | end | |
|
63 | end | |
|
64 | end | |
|
54 | 65 | end |
|
55 | 66 | |
|
56 | 67 | def test_array_with_content_tags |
General Comments 0
You need to be logged in to leave comments.
Login now