From: Jean-Baptiste Barth Date: Sun, 5 May 2013 08:19:17 +0000 (+0000) Subject: Add status to /users/:id API for admins (#13948). X-Git-Tag: 2.4.0~408 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ec4dbbced5d98f4f8ac599b4b2bc6ba0b4dbfcd1;p=redmine.git Add status to /users/:id API for admins (#13948). Patch by Kambiz Darabi git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11790 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/views/users/show.api.rsb b/app/views/users/show.api.rsb index 7168cb94f..e4c49f9b8 100644 --- a/app/views/users/show.api.rsb +++ b/app/views/users/show.api.rsb @@ -7,6 +7,7 @@ api.user do api.created_on @user.created_on api.last_login_on @user.last_login_on api.api_key @user.api_key if User.current.admin? || (User.current == @user) + api.status @user.status if User.current.admin? render_api_custom_values @user.visible_custom_field_values, api diff --git a/test/integration/api_test/users_test.rb b/test/integration/api_test/users_test.rb index 7f72872a2..f90e8cb3d 100644 --- a/test/integration/api_test/users_test.rb +++ b/test/integration/api_test/users_test.rb @@ -120,6 +120,18 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base assert_tag 'user', :child => {:tag => 'api_key', :content => User.find(2).api_key} end + test "GET /users/:id should not return status for standard user" do + get '/users/3.xml', {}, credentials('jsmith') + assert_response :success + assert_no_tag 'user', :child => {:tag => 'status'} + end + + test "GET /users/:id should return status for administrators" do + get '/users/2.xml', {}, credentials('admin') + assert_response :success + assert_tag 'user', :child => {:tag => 'status', :content => User.find(1).status.to_s} + end + context "POST /users" do context "with valid parameters" do setup do