From 735a83c596156e32f8cc686207eecddc029d7629 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 3 Dec 2010 13:52:07 +0000 Subject: Converts IssuesController to use the new API template system and makes xml/json responses consistent (#6136). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4458 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/integration/api_test/issues_test.rb | 6 +++--- test/unit/lib/redmine/views/builders/json_test.rb | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/integration/api_test/issues_test.rb b/test/integration/api_test/issues_test.rb index 1c1f3f8b7..d7bc785c0 100644 --- a/test/integration/api_test/issues_test.rb +++ b/test/integration/api_test/issues_test.rb @@ -74,7 +74,7 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest get '/issues.json?status_id=5' json = ActiveSupport::JSON.decode(response.body) - status_ids_used = json.collect {|j| j['status_id'] } + status_ids_used = json['issues'].collect {|j| j['status']['id'] } assert_equal 3, status_ids_used.length assert status_ids_used.all? {|id| id == 5 } end @@ -160,7 +160,7 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest end json = ActiveSupport::JSON.decode(response.body) - assert_equal "can't be blank", json.first['subject'] + assert json['errors'].include?(['subject', "can't be blank"]) end end @@ -300,7 +300,7 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest put '/issues/6.json', @parameters, @headers json = ActiveSupport::JSON.decode(response.body) - assert_equal "can't be blank", json.first['subject'] + assert json['errors'].include?(['subject', "can't be blank"]) 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 52e6b9ca6..195fba020 100644 --- a/test/unit/lib/redmine/views/builders/json_test.rb +++ b/test/unit/lib/redmine/views/builders/json_test.rb @@ -28,6 +28,15 @@ class Redmine::Views::Builders::JsonTest < HelperTestCase end end + def test_hash_hash + assert_json_output({'person' => {'name' => 'Ryan', 'birth' => {'city' => 'London', 'country' => 'UK'}}}) do |b| + b.person do + b.name 'Ryan' + b.birth :city => 'London', :country => 'UK' + end + end + end + def test_array assert_json_output({'books' => [{'title' => 'Book 1', 'author' => 'B. Smith'}, {'title' => 'Book 2', 'author' => 'G. Cooper'}]}) do |b| b.array :books do |b| -- cgit v1.2.3