Commit bf59ed3c authored by Grzegorz Bizon's avatar Grzegorz Bizon

Simplify how we set pipeline builds user on creation

parent 713502b0
...@@ -17,8 +17,6 @@ module Gitlab ...@@ -17,8 +17,6 @@ module Gitlab
# Populate pipeline with all stages and builds from pipeline seeds. # Populate pipeline with all stages and builds from pipeline seeds.
# #
pipeline.stage_seeds.each do |stage| pipeline.stage_seeds.each do |stage|
stage.user = current_user
pipeline.stages << stage.to_resource pipeline.stages << stage.to_resource
stage.seeds.each do |build| stage.seeds.each do |build|
......
...@@ -17,15 +17,7 @@ module Gitlab ...@@ -17,15 +17,7 @@ module Gitlab
.fabricate(attributes.delete(:except)) .fabricate(attributes.delete(:except))
end end
# TODO, use pipeline.user ?
#
def user=(current_user)
@attributes.merge!(user: current_user)
end
def included? def included?
# TODO specs for passing a seed object for lazy resource evaluation
#
strong_memoize(:inclusion) do strong_memoize(:inclusion) do
@only.all? { |spec| spec.satisfied_by?(@pipeline, self) } && @only.all? { |spec| spec.satisfied_by?(@pipeline, self) } &&
@except.none? { |spec| spec.satisfied_by?(@pipeline, self) } @except.none? { |spec| spec.satisfied_by?(@pipeline, self) }
...@@ -36,6 +28,7 @@ module Gitlab ...@@ -36,6 +28,7 @@ module Gitlab
@attributes.merge( @attributes.merge(
pipeline: @pipeline, pipeline: @pipeline,
project: @pipeline.project, project: @pipeline.project,
user: @pipeline.user,
ref: @pipeline.ref, ref: @pipeline.ref,
tag: @pipeline.tag, tag: @pipeline.tag,
trigger_request: @pipeline.legacy_trigger, trigger_request: @pipeline.legacy_trigger,
......
...@@ -17,10 +17,6 @@ module Gitlab ...@@ -17,10 +17,6 @@ module Gitlab
end end
end end
def user=(current_user)
@seeds.each { |seed| seed.user = current_user }
end
def attributes def attributes
{ name: @attributes.fetch(:name), { name: @attributes.fetch(:name),
pipeline: @pipeline, pipeline: @pipeline,
......
...@@ -21,16 +21,6 @@ describe Gitlab::Ci::Pipeline::Seed::Build do ...@@ -21,16 +21,6 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
end end
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 describe '#to_resource' do
it 'returns a valid build resource' do it 'returns a valid build resource' do
expect(subject.to_resource).to be_a(::Ci::Build) expect(subject.to_resource).to be_a(::Ci::Build)
......
...@@ -95,16 +95,6 @@ describe Gitlab::Ci::Pipeline::Seed::Stage do ...@@ -95,16 +95,6 @@ describe Gitlab::Ci::Pipeline::Seed::Stage do
end end
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 describe '#to_resource' do
it 'builds a valid stage object with all builds' do it 'builds a valid stage object with all builds' do
subject.to_resource.save! subject.to_resource.save!
......
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