From 6a6a69f4afbe0107a75df018b662f02b5ec0166a Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Thu, 11 Aug 2016 20:54:02 +0200 Subject: Use state machine for pipeline event processing --- app/models/commit_status.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/models/commit_status.rb') diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 3ab44461179..64ce5431d63 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -74,13 +74,13 @@ class CommitStatus < ActiveRecord::Base around_transition any => [:success, :failed, :canceled] do |commit_status, block| block.call - commit_status.pipeline.process! if commit_status.pipeline + commit_status.pipeline.try(:process!) end - around_transition any => [:pending, :running] do |commit_status, block| - block.call + # Try to update the pipeline status - commit_status.pipeline.reload_status! if commit_status.pipeline + after_transition do |commit_status, transition| + commit_status.pipeline.try(:update_status) unless transition.loopback? end end -- cgit v1.2.1