summaryrefslogtreecommitdiffstats
path: root/test/integration
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-06 16:32:50 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-06 16:32:50 +0000
commitcdcf813fa784f9e84f99e74dae8c30b8ef4494b8 (patch)
treed11ebd8a679839108481ba8896078a20a52f76cf /test/integration
parentdfbab5d61ee7b106a715a353074053041312b9b0 (diff)
downloadredmine-cdcf813fa784f9e84f99e74dae8c30b8ef4494b8.tar.gz
redmine-cdcf813fa784f9e84f99e74dae8c30b8ef4494b8.zip
Adds membership ids to /users/:id API response.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8805 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/api_test/users_test.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/integration/api_test/users_test.rb b/test/integration/api_test/users_test.rb
index 744a09ee4..398666985 100644
--- a/test/integration/api_test/users_test.rb
+++ b/test/integration/api_test/users_test.rb
@@ -34,20 +34,48 @@ class ApiTest::UsersTest < ActionController::IntegrationTest
should "return requested user" do
get '/users/2.xml'
+ assert_response :success
assert_tag :tag => 'user',
:child => {:tag => 'id', :content => '2'}
end
+
+ context "with include=memberships" do
+ should "include memberships" do
+ get '/users/2.xml?include=memberships'
+
+ assert_response :success
+ assert_tag :tag => 'memberships',
+ :parent => {:tag => 'user'},
+ :children => {:count => 1}
+ end
+ end
end
context ".json" do
should "return requested user" do
get '/users/2.json'
+ assert_response :success
json = ActiveSupport::JSON.decode(response.body)
assert_kind_of Hash, json
assert_kind_of Hash, json['user']
assert_equal 2, json['user']['id']
end
+
+ context "with include=memberships" do
+ should "include memberships" do
+ get '/users/2.json?include=memberships'
+
+ assert_response :success
+ json = ActiveSupport::JSON.decode(response.body)
+ assert_kind_of Array, json['user']['memberships']
+ assert_equal [{
+ "id"=>1,
+ "project"=>{"name"=>"eCookbook", "id"=>1},
+ "roles"=>[{"name"=>"Manager", "id"=>1}]
+ }], json['user']['memberships']
+ end
+ end
end
end