summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-29 18:29:09 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-29 18:29:09 +0000
commit0c5af16e14570a384e154430cd1e9fa123cdf579 (patch)
treee8ad2072cec8fe9d607fab861555236cd32c2d0d /test
parent64b59f150264a34001681a3a41fd05be199fc1d3 (diff)
downloadredmine-0c5af16e14570a384e154430cd1e9fa123cdf579.tar.gz
redmine-0c5af16e14570a384e154430cd1e9fa123cdf579.zip
Support for nested array in API builder.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8720 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/unit/lib/redmine/views/builders/json_test.rb13
-rw-r--r--test/unit/lib/redmine/views/builders/xml_test.rb13
2 files changed, 26 insertions, 0 deletions
diff --git a/test/unit/lib/redmine/views/builders/json_test.rb b/test/unit/lib/redmine/views/builders/json_test.rb
index 1f09f3718..8e09d9b29 100644
--- a/test/unit/lib/redmine/views/builders/json_test.rb
+++ b/test/unit/lib/redmine/views/builders/json_test.rb
@@ -73,6 +73,19 @@ class Redmine::Views::Builders::JsonTest < ActiveSupport::TestCase
end
end
+ def test_nested_arrays
+ assert_json_output({'books' => [{'authors' => ['B. Smith', 'G. Cooper']}]}) do |b|
+ b.array :books do |books|
+ books.book do |book|
+ book.array :authors do |authors|
+ authors.author 'B. Smith'
+ authors.author 'G. Cooper'
+ end
+ end
+ end
+ end
+ end
+
def assert_json_output(expected, &block)
builder = Redmine::Views::Builders::Json.new
block.call(builder)
diff --git a/test/unit/lib/redmine/views/builders/xml_test.rb b/test/unit/lib/redmine/views/builders/xml_test.rb
index cdac8da2b..0f895cc93 100644
--- a/test/unit/lib/redmine/views/builders/xml_test.rb
+++ b/test/unit/lib/redmine/views/builders/xml_test.rb
@@ -46,6 +46,19 @@ class Redmine::Views::Builders::XmlTest < ActiveSupport::TestCase
end
end
+ def test_nested_arrays
+ assert_xml_output('<books type="array"><book><authors type="array"><author>B. Smith</author><author>G. Cooper</author></authors></book></books>') do |b|
+ b.array :books do |books|
+ books.book do |book|
+ book.array :authors do |authors|
+ authors.author 'B. Smith'
+ authors.author 'G. Cooper'
+ end
+ end
+ end
+ end
+ end
+
def assert_xml_output(expected, &block)
builder = Redmine::Views::Builders::Xml.new
block.call(builder)