3 class Arvados::V1::LinksControllerTest < ActionController::TestCase
5 test "no symbol keys in serialized hash" do
7 properties: {username: 'testusername'},
10 tail_uuid: users(:admin).uuid,
11 head_uuid: virtual_machines(:testvm).uuid
14 [link, link.to_json].each do |formatted_link|
15 post :create, link: formatted_link
16 assert_response :success
17 assert_not_nil assigns(:object)
18 assert_equal 'testusername', assigns(:object).properties['username']
19 assert_equal false, assigns(:object).properties.has_key?(:username)
23 test "head must exist" do
27 tail_uuid: users(:active).uuid,
28 head_uuid: 'zzzzz-tpzed-xyzxyzxerrrorxx'
31 post :create, link: link
35 test "tail must exist" do
39 head_uuid: users(:active).uuid,
40 tail_uuid: 'zzzzz-tpzed-xyzxyzxerrrorxx'
43 post :create, link: link
47 test "tail must be visible by user" do
51 head_uuid: users(:active).uuid,
52 tail_uuid: virtual_machines(:testvm).uuid
54 authorize_with :active
55 post :create, link: link
59 test "filter links with 'is_a' operator" do
62 filters: [ ['tail_uuid', 'is_a', 'arvados#user'] ]
64 assert_response :success
65 found = assigns(:objects)
66 assert_not_equal 0, found.count
67 assert_equal found.count, (found.select { |f| f.tail_uuid.match /[a-z0-9]{5}-tpzed-[a-z0-9]{15}/}).count
70 test "filter links with 'is_a' operator with more than one" do
73 filters: [ ['tail_uuid', 'is_a', ['arvados#user', 'arvados#group'] ] ],
75 assert_response :success
76 found = assigns(:objects)
77 assert_not_equal 0, found.count
78 assert_equal found.count, (found.select { |f| f.tail_uuid.match /[a-z0-9]{5}-(tpzed|j7d0g)-[a-z0-9]{15}/}).count
81 test "filter links with 'is_a' operator with bogus type" do
84 filters: [ ['tail_uuid', 'is_a', ['arvados#bogus'] ] ],
86 assert_response :success
87 found = assigns(:objects)
88 assert_equal 0, found.count
91 test "filter links with 'is_a' operator with collection" do
94 filters: [ ['head_uuid', 'is_a', ['arvados#collection'] ] ],
96 assert_response :success
97 found = assigns(:objects)
98 assert_response :success
99 found = assigns(:objects)
100 assert_not_equal 0, found.count
101 assert_equal found.count, (found.select { |f| f.head_uuid.match /[a-f0-9]{32}\+\d+/}).count