Commit ce1cc82a72aec9ec0121646d3b9c27137b95cc49

Authored by Leandro Santos
Committed by Rodrigo Souto
1 parent 9c330a8c

adding tests for user endpoint

lib/api/v1/users.rb
... ... @@ -12,7 +12,7 @@ module API
12 12 end
13 13  
14 14 get ":id" do
15   - present environment.users.find(params[:id]), :with => Entities::User
  15 + present environment.users.find_by_id(params[:id]), :with => Entities::User
16 16 end
17 17  
18 18 get ":id/permissions" do
... ...
test/unit/api/users_test.rb
... ... @@ -12,9 +12,16 @@ class UsersTest < ActiveSupport::TestCase
12 12 assert_includes json["users"].map { |a| a["login"] }, user.login
13 13 end
14 14  
  15 + should 'get user' do
  16 + get "/api/v1/users/#{user.id}?#{params.to_query}"
  17 + json = JSON.parse(last_response.body)
  18 + assert_equal user.id, json['user']['id']
  19 + end
  20 +
  21 +
15 22 should 'list user permissions' do
16 23 community = fast_create(Community)
17   - community.add_admin(user.person)
  24 + community.add_admin(person)
18 25 get "/api/v1/users/#{user.id}/?#{params.to_query}"
19 26 json = JSON.parse(last_response.body)
20 27 assert_includes json["user"]["permissions"], community.identifier
... ...