Merge branch '10790-crunch-job-log-timeout' refs #10790
[arvados.git] / services / api / test / functional / arvados / v1 / collections_controller_test.rb
index cc759a6c3ec9e646580c7d745debd9e8592c3b3c..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,
@@ -973,6 +973,26 @@ EOS
     c = Collection.unscoped.find_by_uuid(uuid)
     assert_operator c.trash_at, :<, db_current_time
     assert_operator c.delete_at, :<, db_current_time
-    assert_equal c.delete_at, c.trash_at + Rails.configuration.blob_signature_ttl
+  end
+
+  ['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, {
+        id: uuid,
+      }
+      assert_response 200
+      c = Collection.unscoped.find_by_uuid(uuid)
+      assert_operator c.trash_at, :<, db_current_time
+      assert_operator c.delete_at, :>=, time_before_trashing + Rails.configuration.default_trash_lifetime
+    end
   end
 end