16470: Fixes reload() API to match the overridden function.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Mon, 20 Jul 2020 14:40:38 +0000 (11:40 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Wed, 5 Aug 2020 13:36:17 +0000 (10:36 -0300)
reload()'s documentation states: "...in addition to the in-place modification
the method returns self for convenience."

https://api.rubyonrails.org/v5.1.7/classes/ActiveRecord/Persistence.html#method-i-reload

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

services/api/app/models/arvados_model.rb
services/api/app/models/collection.rb

index 01a31adb91967c0cb3648e364b3af7c891fd28f0..80ea0c0b7f07e3051d8f6fa355178ff071a9b860 100644 (file)
@@ -137,6 +137,7 @@ class ArvadosModel < ApplicationRecord
   def reload(*args)
     super
     log_start_state
+    self
   end
 
   def self.create raw_params={}, *args
index 996981dba798c03559bb914b54daf0e8725f57a0..8f724e1f5f94bee57982a260e6caa660f81f8ac9 100644 (file)
@@ -262,8 +262,7 @@ class Collection < ArvadosModel
     # Put aside the changes because with_lock requires an explicit record reload
     changes = self.changes
     snapshot = nil
-    reload
-    with_lock do
+    reload.with_lock do
       # Copy the original state to save it as old version
       if should_preserve_version
         snapshot = self.dup