API User details: format tweaks

- _show_ to return single user only
- remove nesting for languages
This commit is contained in:
mmd-osm 2020-09-18 21:04:38 +02:00
parent dff8effc13
commit 37a7996d94
3 changed files with 11 additions and 8 deletions

View file

@ -54,11 +54,7 @@ json.user do
end
end
if user.languages
json.languages do
json.array! user.languages.split(",")
end
end
json.languages user.languages if user.languages?
json.messages do
json.received do

View file

@ -1,3 +1 @@
json.users([@user]) do |user|
json.partial! user
end
json.partial! @user

View file

@ -81,6 +81,15 @@ module Api
# check that a non-existent user is not returned
get api_user_path(:id => 0)
assert_response :not_found
# check that a visible user is returned properly in json
get api_user_path(:id => user.id, :format => "json")
assert_response :success
assert_equal "application/json", response.media_type
js = ActiveSupport::JSON.decode(@response.body)
assert_not_nil js
assert_equal user.id, js["user"]["id"]
end
def test_details