diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-08-12 12:53:27 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-08-12 12:53:27 +0300 |
commit | ad3e1edcfce1e24fb9889d5d73852680cf4facf9 (patch) | |
tree | e8054ae4ad1b0d6882971cbeda3ff4c6fa59187e /app | |
parent | e1f05b932de5553462793fb88fdea2ca54072d40 (diff) |
Added specs for started_at and finished_at
Diffstat (limited to 'app')
-rw-r--r-- | app/models/ci/pipeline.rb | 15 |
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 |