diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-03-21 10:12:01 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-03-21 10:12:01 +0100 |
commit | 6f20134d7177bfd50cf064153832115c095a13ef (patch) | |
tree | 331df50e9ff48f4c5a10058c239f2e606258ebfb | |
parent | 3145cbaaa0b8d267f91bf26b52ca28b21f225745 (diff) | |
download | gitlab-ce-6f20134d7177bfd50cf064153832115c095a13ef.tar.gz |
Remove legacy service for creating pipeline stages
-rw-r--r-- | app/services/ci/create_pipeline_stages_service.rb | 10 | ||||
-rw-r--r-- | lib/gitlab/ci/pipeline/chain/create.rb | 7 | ||||
-rw-r--r-- | lib/gitlab/ci/pipeline/seed/base.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/pipeline/seed/stage.rb | 8 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb | 6 |
5 files changed, 9 insertions, 24 deletions
diff --git a/app/services/ci/create_pipeline_stages_service.rb b/app/services/ci/create_pipeline_stages_service.rb deleted file mode 100644 index 5c3530393f7..00000000000 --- a/app/services/ci/create_pipeline_stages_service.rb +++ /dev/null @@ -1,10 +0,0 @@ -module Ci - class CreatePipelineStagesService < BaseService - def execute(pipeline) - pipeline.stage_seeds.each do |seed| - seed.user = current_user - seed.create! - end - end - end -end diff --git a/lib/gitlab/ci/pipeline/chain/create.rb b/lib/gitlab/ci/pipeline/chain/create.rb index 9f5c141ad14..753d0e89b1e 100644 --- a/lib/gitlab/ci/pipeline/chain/create.rb +++ b/lib/gitlab/ci/pipeline/chain/create.rb @@ -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. diff --git a/lib/gitlab/ci/pipeline/seed/base.rb b/lib/gitlab/ci/pipeline/seed/base.rb index 6af3f5e5603..db9706924bb 100644 --- a/lib/gitlab/ci/pipeline/seed/base.rb +++ b/lib/gitlab/ci/pipeline/seed/base.rb @@ -7,7 +7,7 @@ module Gitlab raise NotImplementedError end - def excluded? + def included? raise NotImplementedError end diff --git a/lib/gitlab/ci/pipeline/seed/stage.rb b/lib/gitlab/ci/pipeline/seed/stage.rb index 3a532e09909..7c1ff041470 100644 --- a/lib/gitlab/ci/pipeline/seed/stage.rb +++ b/lib/gitlab/ci/pipeline/seed/stage.rb @@ -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 diff --git a/spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb index 30142e356a5..c06772a976e 100644 --- a/spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb @@ -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 |