3 class ArvadosBaseTest < ActiveSupport::TestCase
4 test '#save does not send unchanged string attributes' do
6 fixture = api_fixture("collections")["foo_collection_in_aproject"]
7 c = Collection.find(fixture['uuid'])
9 new_name = 'name changed during test'
13 stub_api_client.expects(:post).with do |url, query, opts={}|
16 end.returns fake_api_response('{}', 200, {})
20 updates = JSON.parse got_query['collection']
21 assert_equal updates['name'], new_name
22 refute_includes updates, 'description'
23 refute_includes updates, 'manifest_text'
27 test '#save does not send unchanged attributes missing because of select' do
29 fixture = api_fixture("collections")["foo_collection_in_aproject"]
31 filter([['uuid','=',fixture['uuid']]]).
34 assert_equal nil, c.properties
38 stub_api_client.expects(:post).with do |url, query, opts={}|
41 end.returns fake_api_response('{}', 200, {})
45 updates = JSON.parse got_query['collection']
46 assert_includes updates, 'name'
47 refute_includes updates, 'description'
48 refute_includes updates, 'properties'
55 ].each do |init_props|
56 test "#save sends serialized attributes if changed from #{init_props}" do
58 fixture = api_fixture("collections")["foo_collection_in_aproject"]
59 c = Collection.find(fixture['uuid'])
62 c.properties = init_props if init_props
68 stub_api_client.expects(:post).with do |url, query, opts={}|
71 end.returns fake_api_response('{"etag":"fake","uuid":"fake"}', 200, {})
73 c.properties['baz'] = 'qux'
76 updates = JSON.parse got_query['collection']
77 assert_includes updates, 'properties'