Commit 9074ef539ca5a4d2ef1b8815f5f2171dbe198c59

Authored by Victor Costa
Committed by Rodrigo Souto
1 parent d47207b7

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 82 assert_includes json["users"].map { |a| a["login"] }, user.login
83 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 107 end
... ...