Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2019-10-19 09:06:01 +00:00
parent ca9530a73b
commit 5fe23e59a7
4 changed files with 26 additions and 4 deletions

View file

@ -22,7 +22,7 @@ module Gitlab
# If there is a validation error on environment creation, such as # If there is a validation error on environment creation, such as
# the name contains invalid character, the job will fall back to a # the name contains invalid character, the job will fall back to a
# non-environment job. # non-environment job.
return unless deployment.valid? && deployment.environment.valid? return unless deployment.valid? && deployment.environment.persisted?
deployment.cluster_id = deployment.cluster_id =
deployment.environment.deployment_platform&.cluster_id deployment.environment.deployment_platform&.cluster_id

View file

@ -12,7 +12,7 @@ module Gitlab
end end
def to_resource def to_resource
find_environment || ::Environment.new(attributes) find_environment || ::Environment.create(attributes)
end end
private private

View file

@ -23,9 +23,9 @@ describe Gitlab::Ci::Pipeline::Seed::Environment do
} }
end end
it 'returns an environment object' do it 'returns a persisted environment object' do
expect(subject).to be_a(Environment) expect(subject).to be_a(Environment)
expect(subject).not_to be_persisted expect(subject).to be_persisted
expect(subject.project).to eq(project) expect(subject.project).to eq(project)
expect(subject.name).to eq('production') expect(subject.name).to eq('production')
end end

View file

@ -736,6 +736,28 @@ describe Ci::CreatePipelineService do
end end
end end
context 'when environment with duplicate names' do
let(:ci_yaml) do
{
deploy: { environment: { name: 'production' }, script: 'ls' },
deploy_2: { environment: { name: 'production' }, script: 'ls' }
}
end
before do
stub_ci_pipeline_yaml_file(YAML.dump(ci_yaml))
end
it 'creates a pipeline with the environment' do
result = execute_service
expect(result).to be_persisted
expect(Environment.find_by(name: 'production')).to be_present
expect(result.builds.first.deployment).to be_persisted
expect(result.builds.first.deployment.deployable).to be_a(Ci::Build)
end
end
context 'when builds with auto-retries are configured' do context 'when builds with auto-retries are configured' do
let(:pipeline) { execute_service } let(:pipeline) { execute_service }
let(:rspec_job) { pipeline.builds.find_by(name: 'rspec') } let(:rspec_job) { pipeline.builds.find_by(name: 'rspec') }