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 ...@@ -2,14 +2,12 @@ module Gitlab
module Ci module Ci
module Status module Status
module Build module Build
class Action < SimpleDelegator class Action < Status::Extended
include Status::Extended
def label def label
if has_action? if has_action?
__getobj__.label @status.label
else else
"#{__getobj__.label} (not allowed)" "#{@status.label} (not allowed)"
end end
end end
......
...@@ -2,9 +2,7 @@ module Gitlab ...@@ -2,9 +2,7 @@ module Gitlab
module Ci module Ci
module Status module Status
module Build module Build
class Cancelable < SimpleDelegator class Cancelable < Status::Extended
include Status::Extended
def has_action? def has_action?
can?(user, :update_build, subject) can?(user, :update_build, subject)
end end
......
...@@ -2,9 +2,7 @@ module Gitlab ...@@ -2,9 +2,7 @@ module Gitlab
module Ci module Ci
module Status module Status
module Build module Build
class FailedAllowed < SimpleDelegator class FailedAllowed < Status::Extended
include Status::Extended
def label def label
'failed (allowed to fail)' 'failed (allowed to fail)'
end end
......
...@@ -2,9 +2,7 @@ module Gitlab ...@@ -2,9 +2,7 @@ module Gitlab
module Ci module Ci
module Status module Status
module Build module Build
class Play < SimpleDelegator class Play < Status::Extended
include Status::Extended
def label def label
'manual play action' 'manual play action'
end end
......
...@@ -2,9 +2,7 @@ module Gitlab ...@@ -2,9 +2,7 @@ module Gitlab
module Ci module Ci
module Status module Status
module Build module Build
class Retryable < SimpleDelegator class Retryable < Status::Extended
include Status::Extended
def has_action? def has_action?
can?(user, :update_build, subject) can?(user, :update_build, subject)
end end
......
...@@ -2,9 +2,7 @@ module Gitlab ...@@ -2,9 +2,7 @@ module Gitlab
module Ci module Ci
module Status module Status
module Build module Build
class Stop < SimpleDelegator class Stop < Status::Extended
include Status::Extended
def label def label
'manual stop action' 'manual stop action'
end end
......
module Gitlab module Gitlab
module Ci module Ci
module Status module Status
module Extended class Extended < SimpleDelegator
extend ActiveSupport::Concern def initialize(status)
super(@status = status)
end
class_methods do def self.matches?(_subject, _user)
def matches?(_subject, _user)
raise NotImplementedError raise NotImplementedError
end end
end end
end end
end end
end
end end
...@@ -2,9 +2,7 @@ module Gitlab ...@@ -2,9 +2,7 @@ module Gitlab
module Ci module Ci
module Status module Status
module Pipeline module Pipeline
class Blocked < SimpleDelegator class Blocked < Status::Extended
include Status::Extended
def text def text
'blocked' 'blocked'
end end
......
...@@ -5,9 +5,7 @@ module Gitlab ...@@ -5,9 +5,7 @@ module Gitlab
# Extended status used when pipeline or stage passed conditionally. # Extended status used when pipeline or stage passed conditionally.
# This means that failed jobs that are allowed to fail were present. # This means that failed jobs that are allowed to fail were present.
# #
class SuccessWarning < SimpleDelegator class SuccessWarning < Status::Extended
include Status::Extended
def text def text
'passed' 'passed'
end end
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::Ci::Status::Extended do describe Gitlab::Ci::Status::Extended do
subject do
Class.new.include(described_class)
end
it 'requires subclass to implement matcher' do it 'requires subclass to implement matcher' do
expect { subject.matches?(double, double) } expect { described_class.matches?(double, double) }
.to raise_error(NotImplementedError) .to raise_error(NotImplementedError)
end end
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