10538: Mention fixture names in comments when not using fixture finders.
authorTom Clegg <tom@curoverse.com>
Fri, 30 Dec 2016 20:16:31 +0000 (15:16 -0500)
committerTom Clegg <tom@curoverse.com>
Fri, 30 Dec 2016 20:16:31 +0000 (15:16 -0500)
services/api/test/fixtures/collections.yml
services/api/test/functional/arvados/v1/collections_controller_test.rb
services/api/test/unit/collection_test.rb

index 192ed17057a001c89cbb94539075cd77e078049c..2eb873b5d99ad088b97e3dd1f2dbbe4a6692a744 100644 (file)
@@ -221,6 +221,8 @@ collection_to_move_around_in_aproject:
   manifest_text: ". 73feffa4b7f6bb68e44cf984c85f6e88+3 0:3:baz\n"
   name: collection_to_move_around
 
+# Note: collections(:expired_collection) fixture finder won't work
+# because it is not in default scope
 expired_collection:
   uuid: zzzzz-4zz18-mto52zx1s7sn3ih
   portable_data_hash: 0b21a217243bfce5617fb9224b95bcb9+49
@@ -251,6 +253,8 @@ trashed_on_next_sweep:
   manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:expired\n"
   name: trashed_on_next_sweep
 
+# Note: collections(:deleted_on_next_sweep) fixture finder won't work
+# because it is not in default scope
 deleted_on_next_sweep:
   uuid: zzzzz-4zz18-3u1p5umicfpqszp
   portable_data_hash: 0b21a217243bfce5617fb9224b95bcb9+49
index bd331c372cd7492097a14d726d9af9574872fd55..eeeedcee0183d2d7a2d0767c5c2ea5143d7e3fe2 100644 (file)
@@ -933,7 +933,7 @@ EOS
   end
 
   test 'get trashed collection with include_trash' do
-    uuid = 'zzzzz-4zz18-mto52zx1s7sn3ih'
+    uuid = 'zzzzz-4zz18-mto52zx1s7sn3ih' # expired_collection
     authorize_with :active
     get :show, {
       id: uuid,
@@ -943,7 +943,7 @@ EOS
   end
 
   test 'get trashed collection without include_trash' do
-    uuid = 'zzzzz-4zz18-mto52zx1s7sn3ih'
+    uuid = 'zzzzz-4zz18-mto52zx1s7sn3ih' # expired_collection
     authorize_with :active
     get :show, {
       id: uuid,
@@ -964,7 +964,7 @@ EOS
   end
 
   test 'delete long-trashed collection immediately using http DELETE verb' do
-    uuid = 'zzzzz-4zz18-mto52zx1s7sn3ih'
+    uuid = 'zzzzz-4zz18-mto52zx1s7sn3ih' # expired_collection
     authorize_with :active
     delete :destroy, {
       id: uuid,
@@ -975,10 +975,15 @@ EOS
     assert_operator c.delete_at, :<, db_current_time
   end
 
-  ['zzzzz-4zz18-mto52zx1s7sn3ih',
-   'zzzzz-4zz18-5qa38qghh1j3nvv',
-  ].each do |uuid|
-    test "trash collection #{uuid} via trash action with grace period" do
+  ['zzzzz-4zz18-mto52zx1s7sn3ih', # expired_collection
+   :empty_collection_name_in_active_user_home_project,
+  ].each do |fixture|
+    test "trash collection #{fixture} via trash action with grace period" do
+      if fixture.is_a? String
+        uuid = fixture
+      else
+        uuid = collections(fixture).uuid
+      end
       authorize_with :active
       time_before_trashing = db_current_time
       post :trash, {
index d1cb9785938bec789c9ff7098d4747005f6b89a0..4984aad88b7a01ffbb4c226ebc01f91953be771a 100644 (file)
@@ -470,9 +470,8 @@ class CollectionTest < ActiveSupport::TestCase
   end
 
   test "move to trash in SweepTrashedCollections" do
-    uuid = 'zzzzz-4zz18-4guozfh77ewd2f0'
-    c = Collection.where('uuid=? and is_trashed=false', uuid).first
-    assert c
+    c = collections(:trashed_on_next_sweep)
+    refute_empty Collection.where('uuid=? and is_trashed=false', c.uuid)
     assert_raises(ActiveRecord::RecordNotUnique) do
       act_as_user users(:active) do
         Collection.create!(owner_uuid: c.owner_uuid,
@@ -480,8 +479,8 @@ class CollectionTest < ActiveSupport::TestCase
       end
     end
     SweepTrashedCollections.sweep_now
-    c = Collection.unscoped.find_by_uuid(uuid)
-    assert_equal true, c.is_trashed
+    c = Collection.unscoped.where('uuid=? and is_trashed=true', c.uuid).first
+    assert c
     act_as_user users(:active) do
       assert Collection.create!(owner_uuid: c.owner_uuid,
                                 name: c.name)
@@ -489,7 +488,7 @@ class CollectionTest < ActiveSupport::TestCase
   end
 
   test "delete in SweepTrashedCollections" do
-    uuid = 'zzzzz-4zz18-3u1p5umicfpqszp'
+    uuid = 'zzzzz-4zz18-3u1p5umicfpqszp' # deleted_on_next_sweep
     assert_not_empty Collection.unscoped.where(uuid: uuid)
     SweepTrashedCollections.sweep_now
     assert_empty Collection.unscoped.where(uuid: uuid)