Commit c2523a5d authored by Grzegorz Bizon's avatar Grzegorz Bizon

Remove legacy service for creating pipeline stages

parent 0d8a3156
module Ci
class CreatePipelineStagesService < BaseService
def execute(pipeline)
pipeline.stage_seeds.each do |seed|
seed.user = current_user
seed.create!
end
end
end
end
......@@ -11,9 +11,10 @@ module Gitlab
@command.seeds_block&.call(pipeline)
::Ci::CreatePipelineStagesService
.new(project, current_user)
.execute(pipeline)
pipeline.stage_seeds.each do |seed|
seed.user = current_user
seed.to_resource.save!
end
# TODO populate environments with find_or_initialize_by in the chain too.
......
......@@ -7,7 +7,7 @@ module Gitlab
raise NotImplementedError
end
def excluded?
def included?
raise NotImplementedError
end
......
......@@ -31,11 +31,7 @@ module Gitlab
end
def to_resource
::Ci::Stage.new(attributes)
end
def create!
to_resource.tap do |stage|
::Ci::Stage.new(attributes).tap do |stage|
@seeds.each do |seed|
seed.to_resource.tap do |build|
stage.builds << build
......@@ -43,8 +39,6 @@ module Gitlab
end
@pipeline.stages << stage
stage.save!
end
end
end
......
......@@ -65,9 +65,9 @@ describe Gitlab::Ci::Pipeline::Seed::Stage do
end
end
describe '#create!' do
it 'creates all stages and builds' do
subject.create!
describe '#to_resource' do
it 'builds a valid stage object with all builds' do
subject.to_resource.save!
expect(pipeline.reload.stages.count).to eq 1
expect(pipeline.reload.builds.count).to eq 2
......
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