Merge branch 'master' into 11060-all-visible-repos
[arvados.git] / apps / workbench / test / unit / arvados_base_test.rb
index f202fe7fbc4e2af36215f7df386c52703fea3976..e9ac4f82a5b59d6ae85e6767e43e700093b9e0a1 100644 (file)
@@ -24,6 +24,37 @@ class ArvadosBaseTest < ActiveSupport::TestCase
     end
   end
 
+  test '#save does not send unchanged attributes missing because of select' do
+    use_token :active do
+      fixture = api_fixture("collections")["foo_collection_in_aproject"]
+      c = Collection.
+        filter([['uuid','=',fixture['uuid']]]).
+        select(['uuid']).
+        first
+      if 'MissingAttribute check is re-enabled' == true
+        assert_raises ActiveModel::MissingAttributeError do
+          c.properties
+        end
+      else
+        assert_equal({}, c.properties)
+      end
+
+      got_query = nil
+      stub_api_calls
+      stub_api_client.expects(:post).with do |url, query, opts={}|
+        got_query = query
+        true
+      end.returns fake_api_response('{}', 200, {})
+      c.name = 'foo'
+      c.save
+
+      updates = JSON.parse got_query['collection']
+      assert_includes updates, 'name'
+      refute_includes updates, 'description'
+      refute_includes updates, 'properties'
+    end
+  end
+
   [false,
    {},
    {'foo' => 'bar'},