Simplify how we set pipeline builds user on creation

This commit is contained in:
Grzegorz Bizon 2018-03-23 14:52:33 +01:00
parent 713502b002
commit bf59ed3cf9
5 changed files with 1 additions and 34 deletions

View File

@ -17,8 +17,6 @@ module Gitlab
# Populate pipeline with all stages and builds from pipeline seeds.
#
pipeline.stage_seeds.each do |stage|
stage.user = current_user
pipeline.stages << stage.to_resource
stage.seeds.each do |build|

View File

@ -17,15 +17,7 @@ module Gitlab
.fabricate(attributes.delete(:except))
end
# TODO, use pipeline.user ?
#
def user=(current_user)
@attributes.merge!(user: current_user)
end
def included?
# TODO specs for passing a seed object for lazy resource evaluation
#
strong_memoize(:inclusion) do
@only.all? { |spec| spec.satisfied_by?(@pipeline, self) } &&
@except.none? { |spec| spec.satisfied_by?(@pipeline, self) }
@ -36,6 +28,7 @@ module Gitlab
@attributes.merge(
pipeline: @pipeline,
project: @pipeline.project,
user: @pipeline.user,
ref: @pipeline.ref,
tag: @pipeline.tag,
trigger_request: @pipeline.legacy_trigger,

View File

@ -17,10 +17,6 @@ module Gitlab
end
end
def user=(current_user)
@seeds.each { |seed| seed.user = current_user }
end
def attributes
{ name: @attributes.fetch(:name),
pipeline: @pipeline,

View File

@ -21,16 +21,6 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
end
end
describe '#user=' do
let(:user) { build(:user) }
it 'assignes user to a build' do
subject.user = user
expect(subject.attributes).to include(user: user)
end
end
describe '#to_resource' do
it 'returns a valid build resource' do
expect(subject.to_resource).to be_a(::Ci::Build)

View File

@ -95,16 +95,6 @@ describe Gitlab::Ci::Pipeline::Seed::Stage do
end
end
describe '#user=' do
let(:user) { build(:user) }
it 'assignes relevant pipeline attributes' do
subject.user = user
expect(subject.seeds.map(&:attributes)).to all(include(user: user))
end
end
describe '#to_resource' do
it 'builds a valid stage object with all builds' do
subject.to_resource.save!