19675: Merge branch '19675-instance-types-panel' from arvados-workbench2.git
[arvados.git] / services / api / test / unit / owner_test.rb
index e356f4d9fa19806e9fc48f3f41f16bb90e200608..1c1bd93b8169484b78ffe4948c69512c1c89bc4b 100644 (file)
@@ -63,7 +63,7 @@ class OwnerTest < ActiveSupport::TestCase
 
         assert(Specimen.where(uuid: i.uuid).any?,
                "new item should really be in DB")
-        assert(i.update_attributes(owner_uuid: new_o.uuid),
+        assert(i.update(owner_uuid: new_o.uuid),
                "should change owner_uuid from #{o.uuid} to #{new_o.uuid}")
       end
     end
@@ -92,12 +92,8 @@ class OwnerTest < ActiveSupport::TestCase
              "new #{o_class} should really be in DB")
       old_uuid = o.uuid
       new_uuid = o.uuid.sub(/..........$/, rand(2**256).to_s(36)[0..9])
-      if o.respond_to? :update_uuid
-        o.update_uuid(new_uuid: new_uuid)
-      else
-        assert(o.update_attributes(uuid: new_uuid),
-               "should change #{o_class} uuid from #{old_uuid} to #{new_uuid}")
-      end
+      assert(o.update(uuid: new_uuid),
+              "should change #{o_class} uuid from #{old_uuid} to #{new_uuid}")
       assert_equal(false, o_class.where(uuid: old_uuid).any?,
                    "#{old_uuid} should disappear when renamed to #{new_uuid}")
     end
@@ -122,7 +118,7 @@ class OwnerTest < ActiveSupport::TestCase
       assert_equal(true, Specimen.where(owner_uuid: o.uuid).any?,
                    "need something to be owned by #{o.uuid} for this test")
       new_uuid = o.uuid.sub(/..........$/, rand(2**256).to_s(36)[0..9])
-      assert(!o.update_attributes(uuid: new_uuid),
+      assert(!o.update(uuid: new_uuid),
              "should not change uuid of #{ofixt} that owns objects")
     end
   end
@@ -130,7 +126,7 @@ class OwnerTest < ActiveSupport::TestCase
   test "delete User that owns self" do
     o = User.create!
     assert User.where(uuid: o.uuid).any?, "new User should really be in DB"
-    assert_equal(true, o.update_attributes(owner_uuid: o.uuid),
+    assert_equal(true, o.update(owner_uuid: o.uuid),
                  "setting owner to self should work")
 
     skip_check_permissions_against_full_refresh do
@@ -142,21 +138,4 @@ class OwnerTest < ActiveSupport::TestCase
     check_permissions_against_full_refresh
   end
 
-  test "change uuid of User that owns self" do
-    o = User.create!
-    assert User.where(uuid: o.uuid).any?, "new User should really be in DB"
-    assert_equal(true, o.update_attributes(owner_uuid: o.uuid),
-                 "setting owner to self should work")
-    old_uuid = o.uuid
-    new_uuid = o.uuid.sub(/..........$/, rand(2**256).to_s(36)[0..9])
-    o.update_uuid(new_uuid: new_uuid)
-    o = User.find_by_uuid(new_uuid)
-    assert_equal(false, User.where(uuid: old_uuid).any?,
-                 "#{old_uuid} should not be in DB after deleting")
-    assert_equal(true, User.where(uuid: new_uuid).any?,
-                 "#{new_uuid} should be in DB after renaming")
-    assert_equal(new_uuid, User.where(uuid: new_uuid).first.owner_uuid,
-                 "#{new_uuid} should be its own owner in DB after renaming")
-  end
-
 end