Add Ci::Status::Stage

This commit is contained in:
Kamil Trzcinski 2016-12-05 14:28:02 +01:00
parent 2f972ad47b
commit d47aef58cd
3 changed files with 65 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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