Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-08-12 12:53:27 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2016-08-12 12:53:27 +0300
commitad3e1edcfce1e24fb9889d5d73852680cf4facf9 (patch)
treee8054ae4ad1b0d6882971cbeda3ff4c6fa59187e /app
parente1f05b932de5553462793fb88fdea2ca54072d40 (diff)
Added specs for started_at and finished_at
Diffstat (limited to 'app')
-rw-r--r--app/models/ci/pipeline.rb15
1 files changed, 8 insertions, 7 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 6aef91804a2..92fae78fe4e 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -22,10 +22,11 @@ module Ci
state_machine :status, initial: :created do
event :queue do
transition :created => :pending
+ transition any - [:created, :pending] => :running
end
event :run do
- transition [:pending, :success, :failed, :canceled, :skipped] => :running
+ transition any => :running
end
event :skip do
@@ -44,15 +45,15 @@ module Ci
transition any => :canceled
end
- after_transition [:created, :pending] => :running do |pipeline|
- pipeline.update(started_at: Time.now)
+ before_transition [:created, :pending] => :running do |pipeline|
+ pipeline.started_at = Time.now
end
- after_transition any => [:success, :failed, :canceled] do |pipeline|
- pipeline.update(finished_at: Time.now)
+ before_transition any => [:success, :failed, :canceled] do |pipeline|
+ pipeline.finished_at = Time.now
end
- after_transition do |pipeline|
+ before_transition do |pipeline|
pipeline.update_duration
end
end
@@ -245,7 +246,7 @@ module Ci
end
def update_duration
- update(duration: statuses.latest.duration)
+ self.duration = statuses.latest.duration
end
private