3 class Arvados::V1::LinksControllerTest < ActionController::TestCase
5 test "no symbol keys in serialized hash" do
7 properties: {username: 'testusername'},
10 tail_kind: 'arvados#user',
11 tail_uuid: users(:admin).uuid,
12 head_kind: 'arvados#virtualMachine',
13 head_uuid: virtual_machines(:testvm).uuid
16 [link, link.to_json].each do |formatted_link|
17 post :create, link: formatted_link
18 assert_response :success
19 assert_not_nil assigns(:object)
20 assert_equal 'testusername', assigns(:object).properties['username']
21 assert_equal false, assigns(:object).properties.has_key?(:username)
25 test "head must exist" do
29 tail_uuid: users(:active).uuid,
30 head_uuid: 'zzzzz-tpzed-xyzxyzxerrrorxx'
33 post :create, link: link
37 test "tail must exist" do
41 head_uuid: users(:active).uuid,
42 tail_uuid: 'zzzzz-tpzed-xyzxyzxerrrorxx'
45 post :create, link: link
49 test "tail must be visible by user" do
53 head_uuid: users(:active).uuid,
54 tail_uuid: virtual_machines(:testvm).uuid
56 authorize_with :active
57 post :create, link: link
61 test "filter links with 'is_a' operator" do
64 filters: [ ['tail_uuid', 'is_a', 'arvados#user'] ]
66 assert_response :success
67 found = assigns(:objects)
68 assert_not_equal 0, found.count
69 assert_equal found.count, (found.select { |f| f.tail_uuid.match /[a-z0-9]{5}-tpzed-[a-z0-9]{15}/}).count
72 test "filter links with 'is_a' operator with more than one" do
75 filters: [ ['tail_uuid', 'is_a', ['arvados#user', 'arvados#group'] ] ],
77 assert_response :success
78 found = assigns(:objects)
79 assert_not_equal 0, found.count
80 assert_equal found.count, (found.select { |f| f.tail_uuid.match /[a-z0-9]{5}-(tpzed|j7d0g)-[a-z0-9]{15}/}).count
83 test "filter links with 'is_a' operator with bogus type" do
86 filters: [ ['tail_uuid', 'is_a', ['arvados#bogus'] ] ],
88 assert_response :success
89 found = assigns(:objects)
90 assert_equal 0, found.count
93 test "filter links with 'is_a' operator with collection" do
96 filters: [ ['head_uuid', 'is_a', ['arvados#collection'] ] ],
98 assert_response :success
99 found = assigns(:objects)
100 assert_response :success
101 found = assigns(:objects)
102 assert_not_equal 0, found.count
103 assert_equal found.count, (found.select { |f| f.head_uuid.match /[a-f0-9]{32}\+\d+/}).count