Commit 6f20134d authored by Grzegorz Bizon's avatar Grzegorz Bizon

Remove legacy service for creating pipeline stages

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