diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-12-05 14:28:02 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-12-06 14:13:21 +0100 |
commit | d47aef58cd88fb813390c904bd24525e24d41483 (patch) | |
tree | e3a18c4c2c282a480860a8eadd952441d4d4745c | |
parent | 2f972ad47be9a0c1f9b6acefc6638751145b7078 (diff) | |
download | gitlab-ce-d47aef58cd88fb813390c904bd24525e24d41483.tar.gz |
Add Ci::Status::Stage
-rw-r--r-- | app/models/ci/stage.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/status/stage/common.rb | 24 | ||||
-rw-r--r-- | lib/gitlab/ci/status/stage/factory.rb | 39 |
3 files changed, 65 insertions, 0 deletions
diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb index 8f7727aebaa..2e7f15a16d7 100644 --- a/app/models/ci/stage.rb +++ b/app/models/ci/stage.rb @@ -6,6 +6,8 @@ module Ci attr_reader :pipeline, :name + delegate :project, to: :pipeline + def initialize(pipeline, name: name, status: nil) @pipeline, @name, @status = pipeline, name, status end diff --git a/lib/gitlab/ci/status/stage/common.rb b/lib/gitlab/ci/status/stage/common.rb new file mode 100644 index 00000000000..a1513024c6c --- /dev/null +++ b/lib/gitlab/ci/status/stage/common.rb @@ -0,0 +1,24 @@ +module Gitlab + module Ci + module Status + module Stage + module Common + def has_details? + true + end + + def details_path + namespace_project_pipeline_path(@subject.project.namespace, + @subject.project, + @subject, + anchor: subject.name) + end + + def has_action? + false + end + end + end + end + end +end diff --git a/lib/gitlab/ci/status/stage/factory.rb b/lib/gitlab/ci/status/stage/factory.rb new file mode 100644 index 00000000000..2e485ee22a9 --- /dev/null +++ b/lib/gitlab/ci/status/stage/factory.rb @@ -0,0 +1,39 @@ +module Gitlab + module Ci + module Status + module Stage + class Factory + EXTENDED_STATUSES = [] + + def initialize(stage) + @stage = stage + @status = stage.status || :created + end + + def fabricate! + if extended_status + extended_status.new(core_status) + else + core_status + end + end + + private + + def core_status + Gitlab::Ci::Status + .const_get(@status.capitalize) + .new(@stage) + .extend(Status::Pipeline::Common) + end + + def extended_status + @extended ||= EXTENDED_STATUSES.find do |status| + status.matches?(@stage) + end + end + end + end + end + end +end |