Commit 55cec217 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Refine inheritance model of extended CI/CD statuses

parent 2cc8f43e
......@@ -2,14 +2,12 @@ module Gitlab
module Ci
module Status
module Build
class Action < SimpleDelegator
include Status::Extended
class Action < Status::Extended
def label
if has_action?
__getobj__.label
@status.label
else
"#{__getobj__.label} (not allowed)"
"#{@status.label} (not allowed)"
end
end
......
......@@ -2,9 +2,7 @@ module Gitlab
module Ci
module Status
module Build
class Cancelable < SimpleDelegator
include Status::Extended
class Cancelable < Status::Extended
def has_action?
can?(user, :update_build, subject)
end
......
......@@ -2,9 +2,7 @@ module Gitlab
module Ci
module Status
module Build
class FailedAllowed < SimpleDelegator
include Status::Extended
class FailedAllowed < Status::Extended
def label
'failed (allowed to fail)'
end
......
......@@ -2,9 +2,7 @@ module Gitlab
module Ci
module Status
module Build
class Play < SimpleDelegator
include Status::Extended
class Play < Status::Extended
def label
'manual play action'
end
......
......@@ -2,9 +2,7 @@ module Gitlab
module Ci
module Status
module Build
class Retryable < SimpleDelegator
include Status::Extended
class Retryable < Status::Extended
def has_action?
can?(user, :update_build, subject)
end
......
......@@ -2,9 +2,7 @@ module Gitlab
module Ci
module Status
module Build
class Stop < SimpleDelegator
include Status::Extended
class Stop < Status::Extended
def label
'manual stop action'
end
......
module Gitlab
module Ci
module Status
module Extended
extend ActiveSupport::Concern
class Extended < SimpleDelegator
def initialize(status)
super(@status = status)
end
class_methods do
def matches?(_subject, _user)
raise NotImplementedError
end
def self.matches?(_subject, _user)
raise NotImplementedError
end
end
end
......
......@@ -2,9 +2,7 @@ module Gitlab
module Ci
module Status
module Pipeline
class Blocked < SimpleDelegator
include Status::Extended
class Blocked < Status::Extended
def text
'blocked'
end
......
......@@ -5,9 +5,7 @@ module Gitlab
# Extended status used when pipeline or stage passed conditionally.
# This means that failed jobs that are allowed to fail were present.
#
class SuccessWarning < SimpleDelegator
include Status::Extended
class SuccessWarning < Status::Extended
def text
'passed'
end
......
......@@ -205,7 +205,7 @@ describe Gitlab::Ci::Status::Build::Factory do
it 'matches correct extended statuses' do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::Build::Play,
Gitlab::Ci::Status::Build::Action]
Gitlab::Ci::Status::Build::Action]
end
it 'fabricates action detailed status' do
......
require 'spec_helper'
describe Gitlab::Ci::Status::Extended do
subject do
Class.new.include(described_class)
end
it 'requires subclass to implement matcher' do
expect { subject.matches?(double, double) }
expect { described_class.matches?(double, double) }
.to raise_error(NotImplementedError)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment