api.twofa_scheme user.twofa_scheme
api.status user.status
+ api.auth_source do
+ api.id user.auth_source.id
+ api.name user.auth_source.name
+ end if include_in_api_response?('auth_source') && user.auth_source.present?
+
render_api_custom_values user.visible_custom_field_values, api
end
end
assert_equal 0, json['users'].size
end
+ test "GET /users.json with include=auth_source" do
+ user = User.find(2)
+ user.update(:auth_source_id => 1)
+ get '/users.json?include=auth_source', :headers => credentials('admin')
+
+ json = ActiveSupport::JSON.decode(response.body)
+ assert json.key?('users')
+
+ json['users'].each do | user_json |
+ if user_json['id'] == user.id
+ assert_kind_of Hash, user_json['auth_source']
+ assert_equal user.auth_source.id, user_json['auth_source']['id']
+ assert_equal user.auth_source.name, user_json['auth_source']['name']
+ else
+ assert_nil user_json['auth_source']
+ end
+ end
+ end
+
test "GET /users.json with short filters" do
get '/users.json', headers: credentials('admin'), params: { status: "1|3" }
assert_response :success