Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
ca9530a73b
commit
5fe23e59a7
|
@ -22,7 +22,7 @@ module Gitlab
|
|||
# If there is a validation error on environment creation, such as
|
||||
# the name contains invalid character, the job will fall back to a
|
||||
# non-environment job.
|
||||
return unless deployment.valid? && deployment.environment.valid?
|
||||
return unless deployment.valid? && deployment.environment.persisted?
|
||||
|
||||
deployment.cluster_id =
|
||||
deployment.environment.deployment_platform&.cluster_id
|
||||
|
|
|
@ -12,7 +12,7 @@ module Gitlab
|
|||
end
|
||||
|
||||
def to_resource
|
||||
find_environment || ::Environment.new(attributes)
|
||||
find_environment || ::Environment.create(attributes)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -23,9 +23,9 @@ describe Gitlab::Ci::Pipeline::Seed::Environment do
|
|||
}
|
||||
end
|
||||
|
||||
it 'returns an environment object' do
|
||||
it 'returns a persisted environment object' do
|
||||
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.name).to eq('production')
|
||||
end
|
||||
|
|
|
@ -736,6 +736,28 @@ describe Ci::CreatePipelineService do
|
|||
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
|
||||
let(:pipeline) { execute_service }
|
||||
let(:rspec_job) { pipeline.builds.find_by(name: 'rspec') }
|
||||
|
|
Loading…
Reference in New Issue