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