提交 3731ae09 编写于 作者: L Lin Jen-Shin

CreatePipelineBuildsService would have created env

So we don't have to do it in CreateDeploymentService
Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/11695#note_31322649
上级 b01bc0a0
......@@ -19,12 +19,6 @@ module Ci
)
end
def ensure_persisted_environment
persisted_environment ||
@persisted_environment =
project.environments.create(name: expanded_environment_name)
end
serialize :options # rubocop:disable Cop/ActiverecordSerialize
serialize :yaml_variables, Gitlab::Serializer::Ci::Variables # rubocop:disable Cop/ActiverecordSerialize
......
......@@ -42,7 +42,7 @@ class CreateDeploymentService
end
def environment
@environment ||= job.ensure_persisted_environment
@environment ||= job.persisted_environment
end
def environment_options
......
......@@ -960,36 +960,6 @@ describe Ci::Build, :models do
end
end
describe '#ensure_persisted_environment' do
subject { job.ensure_persisted_environment }
let(:job) do
create(:ci_build,
ref: 'master',
environment: 'staging/$CI_COMMIT_REF_NAME')
end
context 'when there is no environment' do
it 'creates one by the expanded name' do
expect do
expect(subject.name).to eq('staging/master')
end.to change { Environment.count }.by(1)
end
end
context 'when there is already an environment' do
let!(:environment) do
create(:environment, project: job.project, name: 'staging/master')
end
it 'returns the existing environment' do
expect do
expect(subject).to eq(environment)
end.to change { Environment.count }.by(0)
end
end
end
describe '#play' do
let(:build) { create(:ci_build, :manual, pipeline: pipeline) }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册