Commit 9074ef539ca5a4d2ef1b8815f5f2171dbe198c59
Committed by
Rodrigo Souto
1 parent
d47207b7
Exists in
api_tasks
and in
4 other branches
Added more unit tests to grape api
Showing
1 changed file
with
22 additions
and
0 deletions
Show diff stats
test/unit/api_test.rb
@@ -82,4 +82,26 @@ class APITest < ActiveSupport::TestCase | @@ -82,4 +82,26 @@ class APITest < ActiveSupport::TestCase | ||
82 | assert_includes json["users"].map { |a| a["login"] }, user.login | 82 | assert_includes json["users"].map { |a| a["login"] }, user.login |
83 | end | 83 | end |
84 | 84 | ||
85 | + should 'list user permissions' do | ||
86 | + community = fast_create(Community) | ||
87 | + community.add_admin(user.person) | ||
88 | + get "/api/v1/users/#{user.id}/?#{params.to_query}" | ||
89 | + json = JSON.parse(last_response.body) | ||
90 | + assert_includes json["user"]["permissions"], community.identifier | ||
91 | + end | ||
92 | + | ||
93 | + should 'list categories' do | ||
94 | + category = fast_create(Category) | ||
95 | + get "/api/v1/categories/?#{params.to_query}" | ||
96 | + json = JSON.parse(last_response.body) | ||
97 | + assert_includes json["categories"].map { |c| c["name"] }, category.name | ||
98 | + end | ||
99 | + | ||
100 | + should 'get category by id' do | ||
101 | + category = fast_create(Category) | ||
102 | + get "/api/v1/categories/#{category.id}/?#{params.to_query}" | ||
103 | + json = JSON.parse(last_response.body) | ||
104 | + assert_equal category.name, json["category"]["name"] | ||
105 | + end | ||
106 | + | ||
85 | end | 107 | end |