1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
7 class ArvadosBaseTest < ActiveSupport::TestCase
8 test '#save does not send unchanged string attributes' do
10 fixture = api_fixture("collections")["foo_collection_in_aproject"]
11 c = Collection.find(fixture['uuid'])
13 new_name = 'name changed during test'
17 stub_api_client.expects(:post).with do |url, query, opts={}|
20 end.returns fake_api_response('{}', 200, {})
24 updates = JSON.parse got_query['collection']
25 assert_equal updates['name'], new_name
26 refute_includes updates, 'description'
27 refute_includes updates, 'manifest_text'
31 test '#save does not send unchanged attributes missing because of select' do
33 fixture = api_fixture("collections")["foo_collection_in_aproject"]
35 filter([['uuid','=',fixture['uuid']]]).
38 if 'MissingAttribute check is re-enabled' == true
39 assert_raises ActiveModel::MissingAttributeError do
43 assert_equal({}, c.properties)
48 stub_api_client.expects(:post).with do |url, query, opts={}|
51 end.returns fake_api_response('{}', 200, {})
55 updates = JSON.parse got_query['collection']
56 assert_includes updates, 'name'
57 refute_includes updates, 'description'
58 refute_includes updates, 'properties'
65 ].each do |init_props|
66 test "#save sends serialized attributes if changed from #{init_props}" do
68 fixture = api_fixture("collections")["foo_collection_in_aproject"]
69 c = Collection.find(fixture['uuid'])
72 c.properties = init_props if init_props
78 stub_api_client.expects(:post).with do |url, query, opts={}|
81 end.returns fake_api_response('{"etag":"fake","uuid":"fake"}', 200, {})
83 c.properties['baz'] = 'qux'
86 updates = JSON.parse got_query['collection']
87 assert_includes updates, 'properties'