summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-12-05 14:22:41 +0100
committerKamil Trzcinski <ayufan@ayufan.eu>2016-12-06 14:13:21 +0100
commit2f972ad47be9a0c1f9b6acefc6638751145b7078 (patch)
tree3193d0791b0fb36fb63f90b6b6077de815b6a1f8
parentd865aedafc2282f898b4bd2fdfd3660c47203c37 (diff)
downloadgitlab-ce-2f972ad47be9a0c1f9b6acefc6638751145b7078.tar.gz
Preserve stage values and use StaticModel
-rw-r--r--app/models/ci/stage.rb16
1 files changed, 11 insertions, 5 deletions
diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb
index f1cac09c4e9..8f7727aebaa 100644
--- a/app/models/ci/stage.rb
+++ b/app/models/ci/stage.rb
@@ -1,23 +1,29 @@
module Ci
- class Stage < ActiveRecord::Base
- include ActiveModel::Model
+ # Currently this is artificial object, constructed dynamically
+ # We should migrate this object to actual database record in the future
+ class Stage
+ include StaticModel
attr_reader :pipeline, :name
- def initialize(pipeline, name: name, status: status = nil)
+ def initialize(pipeline, name: name, status: nil)
@pipeline, @name, @status = pipeline, name, status
end
+ def to_param
+ name
+ end
+
def status
@status ||= statuses.latest.status
end
def statuses
- pipeline.statuses.where(stage: stage)
+ @statuses ||= pipeline.statuses.where(stage: stage)
end
def builds
- pipeline.builds.where(stage: stage)
+ @builds ||= pipeline.builds.where(stage: stage)
end
end
end