Merge branch 'master' into 10786-remove-centos6-from-build-directory
[arvados.git] / services / api / app / models / collection.rb
index 93d46209276c95a2cc3544ee0c82f437aec6943c..4f774d6f9cc7029759a474938da991cbc83c2f46 100644 (file)
@@ -454,16 +454,18 @@ class Collection < ArvadosModel
   # If trash_at is updated without touching delete_at, automatically
   # update delete_at to a sensible value.
   def default_trash_interval
-    if trash_at && trash_at_changed? && !delete_at_changed?
-      self.delete_at = trash_at + Rails.configuration.default_trash_lifetime.seconds
-    elsif trash_at.nil? && trash_at_changed? && !delete_at_changed?
-      self.delete_at = nil
+    if trash_at_changed? && !delete_at_changed?
+      if trash_at.nil?
+        self.delete_at = nil
+      else
+        self.delete_at = trash_at + Rails.configuration.default_trash_lifetime.seconds
+      end
     end
   end
 
   def validate_trash_and_delete_timing
     if trash_at.nil? != delete_at.nil?
-      errors.add :delete_at, "must be nil if and only if trash_at is nil"
+      errors.add :delete_at, "must be set if trash_at is set, and must be nil otherwise"
     end
 
     earliest_delete = ([@validation_timestamp, trash_at_was].compact.min +