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 if 'MissingAttribute check is re-enabled' == true
35 assert_raises ActiveModel::MissingAttributeError do
39 assert_equal({}, c.properties)
44 stub_api_client.expects(:post).with do |url, query, opts={}|
47 end.returns fake_api_response('{}', 200, {})
51 updates = JSON.parse got_query['collection']
52 assert_includes updates, 'name'
53 refute_includes updates, 'description'
54 refute_includes updates, 'properties'
61 ].each do |init_props|
62 test "#save sends serialized attributes if changed from #{init_props}" do
64 fixture = api_fixture("collections")["foo_collection_in_aproject"]
65 c = Collection.find(fixture['uuid'])
68 c.properties = init_props if init_props
74 stub_api_client.expects(:post).with do |url, query, opts={}|
77 end.returns fake_api_response('{"etag":"fake","uuid":"fake"}', 200, {})
79 c.properties['baz'] = 'qux'
82 updates = JSON.parse got_query['collection']
83 assert_includes updates, 'properties'