[ARVADOS] updated: 5cb205c567c312345376bcd2b7104075b5710d7f

git at public.curoverse.com git at public.curoverse.com
Tue Apr 22 01:00:24 EDT 2014


Summary of changes:
 services/api/app/models/pipeline_instance.rb     |   19 ++++++++++++++++---
 services/api/test/unit/pipeline_instance_test.rb |   17 -----------------
 2 files changed, 16 insertions(+), 20 deletions(-)

       via  5cb205c567c312345376bcd2b7104075b5710d7f (commit)
      from  a3c5fac3f7849cab38bedd313b522b994be17b15 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 5cb205c567c312345376bcd2b7104075b5710d7f
Author: radhika chippada <radhika at curoverse.com>
Date:   Tue Apr 22 00:59:53 2014 -0400

    Set state during save

diff --git a/services/api/app/models/pipeline_instance.rb b/services/api/app/models/pipeline_instance.rb
index 5c60178..211b91a 100644
--- a/services/api/app/models/pipeline_instance.rb
+++ b/services/api/app/models/pipeline_instance.rb
@@ -9,8 +9,9 @@ class PipelineInstance < ArvadosModel
 
   before_validation :bootstrap_components
   before_validation :update_success
-  before_create :verify_status
-  before_save :verify_status
+  before_validation :verify_status
+  before_create :set_state_before_save
+  before_save :set_state_before_save
 
   api_accessible :user, extend: :common do |t|
     t.add :pipeline_template_uuid
@@ -175,7 +176,7 @@ class PipelineInstance < ArvadosModel
         self.active = false
         self.success = true
       end
-    else    # new object create or save
+    elsif components_changed? 
       if !self.state || self.state == New || !self.active
         if PipelineInstance.is_ready self.components
           self.state = Ready
@@ -186,4 +187,16 @@ class PipelineInstance < ArvadosModel
     end
   end
 
+  def set_state_before_save
+    if !self.state || self.state == New
+      if self.active
+        self.state = RunningOnServer
+      elsif PipelineInstance.is_ready self.components
+        self.state = Ready
+      else
+        self.state = New
+      end
+    end
+  end
+
 end
diff --git a/services/api/test/unit/pipeline_instance_test.rb b/services/api/test/unit/pipeline_instance_test.rb
index 0eb3ff9..2192001 100644
--- a/services/api/test/unit/pipeline_instance_test.rb
+++ b/services/api/test/unit/pipeline_instance_test.rb
@@ -62,23 +62,6 @@ class PipelineInstanceTest < ActiveSupport::TestCase
     assert_equal PipelineInstance::Complete, pi.state, 'expected state to be Complete after updating success to true'
     assert !pi.active, 'expected active to be false after update'
     assert pi.success, 'expected success to be true after update'
-
-    pi.update_attribute 'active', true
-    pi = PipelineInstance.find_by_uuid 'zzzzz-xxxxx-f4gneyn6br1xize'
-    assert_equal PipelineInstance::RunningOnServer, pi.state, 'expected state to be RunningOnServer after updating active to true'
-    assert pi.active, 'expected active to be true after update'
-
-    pi.update_attribute 'success', false
-    pi = PipelineInstance.find_by_uuid 'zzzzz-xxxxx-f4gneyn6br1xize'
-    assert_equal PipelineInstance::Failed, pi.state, 'expected state to be Failed after updating success to false'
-    assert !pi.active, 'expected active to be false after update'
-    assert !pi.success, 'expected success to be false for a new pipeline'
-
-    pi.update_attribute 'success', true
-    pi = PipelineInstance.find_by_uuid 'zzzzz-xxxxx-f4gneyn6br1xize'
-    assert_equal PipelineInstance::Complete, pi.state, 'expected state to be Complete after updating success to true'
-    assert !pi.active, 'expected active to be false after update'
-    assert pi.success, 'expected success to be true after update'
   end
 
   test "update attributes for pipeline with two components" do

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list