Commit c7809d09 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Fix rubocop offense in pipeline build seed class

parent 7259ee85
...@@ -5,9 +5,7 @@ module Gitlab ...@@ -5,9 +5,7 @@ module Gitlab
class Build < Seed::Base class Build < Seed::Base
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
attr_reader :pipeline, :attributes delegate :dig, to: :@attributes
delegate :dig, to: :attributes
def initialize(pipeline, attributes) def initialize(pipeline, attributes)
@pipeline = pipeline @pipeline = pipeline
...@@ -23,6 +21,16 @@ module Gitlab ...@@ -23,6 +21,16 @@ module Gitlab
@attributes.merge!(user: current_user) @attributes.merge!(user: current_user)
end end
def included?
strong_memoize(:inclusion) do
only_specs = Gitlab::Ci::Build::Policy.fabricate(@only)
except_specs = Gitlab::Ci::Build::Policy.fabricate(@except)
only_specs.all? { |spec| spec.satisfied_by?(@pipeline) } &&
except_specs.none? { |spec| spec.satisfied_by?(@pipeline) }
end
end
def attributes def attributes
@attributes.merge( @attributes.merge(
pipeline: @pipeline, pipeline: @pipeline,
...@@ -34,16 +42,6 @@ module Gitlab ...@@ -34,16 +42,6 @@ module Gitlab
) )
end end
def included?
strong_memoize(:inclusion) do
only_specs = Gitlab::Ci::Build::Policy.fabricate(@only)
except_specs = Gitlab::Ci::Build::Policy.fabricate(@except)
only_specs.all? { |spec| spec.satisfied_by?(pipeline) } &&
except_specs.none? { |spec| spec.satisfied_by?(pipeline) }
end
end
def to_resource def to_resource
::Ci::Build.new(attributes) ::Ci::Build.new(attributes)
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