Merge remote-tracking branch 'origin/master' into origin-2228-check-filter-uuid-columns
[arvados.git] / services / api / test / integration / valid_links_test.rb
1 require 'test_helper'
2
3 class ValidLinksTest < ActionDispatch::IntegrationTest
4   fixtures :all
5
6   test "tail must exist on update" do
7     admin_auth = {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:admin).api_token}"}
8
9     post "/arvados/v1/links", {
10       :format => :json,
11       :link => {
12         link_class: 'test',
13         name: 'stuff',
14         head_uuid: users(:active).uuid,
15         tail_uuid: virtual_machines(:testvm).uuid
16       }
17     }, admin_auth
18     assert_response :success
19     u = jresponse['uuid']
20
21     put "/arvados/v1/links/#{u}", {
22       :format => :json,
23       :link => {
24         tail_uuid: virtual_machines(:testvm2).uuid
25       }
26     }, admin_auth
27     assert_response :success
28     #puts @response.body
29     #puts jresponse['tail_uuid']
30     #puts virtual_machines(:testvm2)
31     assert_equal virtual_machines(:testvm2).uuid, (ActiveSupport::JSON.decode @response.body)['tail_uuid']
32
33     put "/arvados/v1/links/#{u}", {
34       :format => :json,
35       :link => {
36         tail_uuid: 'zzzzz-tpzed-xyzxyzxerrrorxx'
37       }
38     }, admin_auth
39     assert_response 422
40   end
41
42 end