Merge branch 'master' into 1786-replace-jekyll-with-zenweb
[arvados.git] / services / api / test / integration / collections_api_test.rb
1 require 'test_helper'
2
3 class CollectionsApiTest < ActionDispatch::IntegrationTest
4   fixtures :all
5
6   def jresponse
7     @jresponse ||= ActiveSupport::JSON.decode @response.body
8   end
9
10   test "should get index" do
11     get "/arvados/v1/collections", {:format => :json}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
12     assert_response :success
13     assert_equal "arvados#collectionList", jresponse['kind']
14   end
15
16   test "controller 404 response is json" do
17     get "/arvados/v1/thingsthatdonotexist", {:format => :xml}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
18     assert_response 404
19     assert_equal 1, jresponse['errors'].length
20     assert_equal true, jresponse['errors'][0].is_a?(String)
21   end
22
23   test "object 404 response is json" do
24     get "/arvados/v1/groups/zzzzz-j7d0g-o5ba971173cup4f", {}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
25     assert_response 404
26     assert_equal 1, jresponse['errors'].length
27     assert_equal true, jresponse['errors'][0].is_a?(String)
28   end
29
30 end