Merge branch 'master' into 1776-setup-user-email
[arvados.git] / services / api / test / integration / collections_api_test.rb
index 076b2342a2a64798efb8e478c444532c1c592d45..5fa77c3db9a23acf75d079a01bc3ab9886c9ee99 100644 (file)
@@ -3,28 +3,44 @@ require 'test_helper'
 class CollectionsApiTest < ActionDispatch::IntegrationTest
   fixtures :all
 
-  def jresponse
-    @jresponse ||= ActiveSupport::JSON.decode @response.body
+  test "should get index" do
+    get "/arvados/v1/collections", {:format => :json}, auth(:active)
+    assert_response :success
+    assert_equal "arvados#collectionList", jresponse['kind']
   end
 
-  test "should get index" do
-    get "/arvados/v1/collections", {:format => :json}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
+  test "get index with filters= (empty string)" do
+    get "/arvados/v1/collections", {:format => :json, :filters => ''}, auth(:active)
+    assert_response :success
+    assert_equal "arvados#collectionList", jresponse['kind']
+  end
+
+  test "get index with where= (empty string)" do
+    get "/arvados/v1/collections", {:format => :json, :where => ''}, auth(:active)
     assert_response :success
     assert_equal "arvados#collectionList", jresponse['kind']
   end
 
   test "controller 404 response is json" do
-    get "/arvados/v1/thingsthatdonotexist", {:format => :xml}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
+    get "/arvados/v1/thingsthatdonotexist", {:format => :xml}, auth(:active)
     assert_response 404
     assert_equal 1, jresponse['errors'].length
     assert_equal true, jresponse['errors'][0].is_a?(String)
   end
 
   test "object 404 response is json" do
-    get "/arvados/v1/groups/zzzzz-j7d0g-o5ba971173cup4f", {}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
+    get "/arvados/v1/groups/zzzzz-j7d0g-o5ba971173cup4f", {}, auth(:active)
     assert_response 404
     assert_equal 1, jresponse['errors'].length
     assert_equal true, jresponse['errors'][0].is_a?(String)
   end
 
+  test "store collection as json" do
+    post "/arvados/v1/collections", {
+      format: :json,
+      collection: "{\"manifest_text\":\". bad42fa702ae3ea7d888fef11b46f450+44 0:44:md5sum.txt\\n\",\"uuid\":\"ad02e37b6a7f45bbe2ead3c29a109b8a+54\"}"
+    }, auth(:active)
+    assert_response 200
+    assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', jresponse['uuid']
+  end
 end