Project

General

Profile

Patch #29459 ยป 0001-Expose-the-Admin-flag-on-the-users-api-to-admin-user.patch

Holger Just, 2018-08-29 16:41

View differences:

app/views/users/index.api.rsb
api.user do
api.id user.id
api.login user.login
api.admin user.admin?
api.firstname user.firstname
api.lastname user.lastname
api.mail user.mail
app/views/users/show.api.rsb
api.user do
api.id @user.id
api.login @user.login if User.current.admin? || (User.current == @user)
api.admin @user.admin? if User.current.admin? || (User.current == @user)
api.firstname @user.firstname
api.lastname @user.lastname
api.mail @user.mail if User.current.admin? || !@user.pref.hide_mail
test/integration/api_test/users_test.rb
assert_select 'user status', :text => User.find(1).status.to_s
end
test "GET /users/:id should return admin status for current user" do
get '/users/2.xml', :headers => credentials('jsmith')
assert_response :success
assert_select 'user admin', :text => 'false'
end
test "GET /users/:id should not return admin status for other user" do
get '/users/3.xml', :headers => credentials('jsmith')
assert_response :success
assert_select 'user admin', 0
end
test "POST /users.xml with valid parameters should create the user" do
assert_difference('User.count') do
post '/users.xml',
    (1-1/1)