From 22db59393203f550e0c77e65c650e664667492ab Mon Sep 17 00:00:00 2001 From: radhika chippada Date: Wed, 23 Apr 2014 15:01:41 -0400 Subject: [PATCH] Story 2352: Adding state and components_summary is completed. --- services/api/app/models/pipeline_instance.rb | 2 +- services/api/test/unit/pipeline_instance_test.rb | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/services/api/app/models/pipeline_instance.rb b/services/api/app/models/pipeline_instance.rb index fbe3690637..d314885cd3 100644 --- a/services/api/app/models/pipeline_instance.rb +++ b/services/api/app/models/pipeline_instance.rb @@ -178,7 +178,7 @@ class PipelineInstance < ArvadosModel else return false end - elsif components_changed? + elsif components_changed? if !self.state || self.state == New || !self.active if self.components_look_ready? self.state = Ready diff --git a/services/api/test/unit/pipeline_instance_test.rb b/services/api/test/unit/pipeline_instance_test.rb index 20c833fa10..dfda3cc9c8 100644 --- a/services/api/test/unit/pipeline_instance_test.rb +++ b/services/api/test/unit/pipeline_instance_test.rb @@ -10,6 +10,8 @@ class PipelineInstanceTest < ActiveSupport::TestCase assert !pi.state, 'expected state to be nil because the fixture had no state specified' # save the pipeline and expect state to be New + Thread.current[:user] = users(:admin) + pi.save pi = PipelineInstance.find_by_uuid 'zzzzz-xxxxx-f4gneyn6br1xize' assert_equal PipelineInstance::New, pi.state, 'expected state to be New for new pipeline' @@ -18,6 +20,8 @@ class PipelineInstanceTest < ActiveSupport::TestCase end test "update attributes for pipeline" do + Thread.current[:user] = users(:admin) + pi = pipeline_instances :new_pipeline # add a component with no input and expect state to be New @@ -52,7 +56,7 @@ class PipelineInstanceTest < ActiveSupport::TestCase assert_equal pi.components.size, 1, 'expected one component' assert !pi.active, 'expected active to be false after update' assert !pi.success, 'expected success to be false for a new pipeline' - + pi.active = true pi.save pi = PipelineInstance.find_by_uuid 'zzzzz-xxxxx-f4gneyn6br1xize' @@ -112,7 +116,10 @@ class PipelineInstanceTest < ActiveSupport::TestCase pi.components['first'] = component1 pi.components['second'] = component2 components = pi.components + + Thread.current[:user] = users(:admin) pi.update_attribute 'components', pi.components + pi = PipelineInstance.find_by_uuid 'zzzzz-xxxxx-f4gneyn6br1xize' assert_equal PipelineInstance::New, pi.state, 'expected state to be New after adding component with input' assert_equal pi.components.size, 2, 'expected two components' -- 2.30.2