Merge branch '1748-workbench-view-files'
[arvados.git] / services / api / test / functional / arvados / v1 / collections_controller_test.rb
1 require 'test_helper'
2
3 class Arvados::V1::CollectionsControllerTest < ActionController::TestCase
4
5   test "should get index" do
6     authorize_with :active
7     get :index
8     assert_response :success
9     assert_not_nil assigns(:objects)
10   end
11
12   test "should create" do
13     authorize_with :active
14     post :create, {
15       collection: {
16         manifest_text: ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n",
17         uuid: "d30fe8ae534397864cb96c544f4cf102"
18       }
19     }
20     assert_response :success
21     assert_nil assigns(:objects)
22   end
23
24   test "should create with collection passed as json" do
25     authorize_with :active
26     post :create, {
27       collection: <<-EOS
28       {
29         "manifest_text":". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n",\
30         "uuid":"d30fe8ae534397864cb96c544f4cf102"\
31       }
32       EOS
33     }
34     assert_response :success
35   end
36
37   test "should fail to create with checksum mismatch" do
38     authorize_with :active
39     post :create, {
40       collection: <<-EOS
41       {
42         "manifest_text":". d41d8cd98f00b204e9800998ecf8427e 0:0:bar.txt\n",\
43         "uuid":"d30fe8ae534397864cb96c544f4cf102"\
44       }
45       EOS
46     }
47     assert_response 422
48   end
49
50 end