diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-19 09:06:01 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-19 09:06:01 +0000 |
commit | 5fe23e59a703eb3531d42b6dfdebaf51521dd969 (patch) | |
tree | 7e8132b72fbc62177bbc432426222a7aa5949332 | |
parent | ca9530a73b95eeb5fac76f9d543c2a3a550a5b76 (diff) | |
download | gitlab-ce-5fe23e59a703eb3531d42b6dfdebaf51521dd969.tar.gz |
Add latest changes from gitlab-org/gitlab@master
-rw-r--r-- | lib/gitlab/ci/pipeline/seed/deployment.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/pipeline/seed/environment.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/pipeline/seed/environment_spec.rb | 4 | ||||
-rw-r--r-- | spec/services/ci/create_pipeline_service_spec.rb | 22 |
4 files changed, 26 insertions, 4 deletions
diff --git a/lib/gitlab/ci/pipeline/seed/deployment.rb b/lib/gitlab/ci/pipeline/seed/deployment.rb index 238cd845a0e..8c90f03cb1d 100644 --- a/lib/gitlab/ci/pipeline/seed/deployment.rb +++ b/lib/gitlab/ci/pipeline/seed/deployment.rb @@ -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 diff --git a/lib/gitlab/ci/pipeline/seed/environment.rb b/lib/gitlab/ci/pipeline/seed/environment.rb index 813a9e9e399..2d3a1e702f9 100644 --- a/lib/gitlab/ci/pipeline/seed/environment.rb +++ b/lib/gitlab/ci/pipeline/seed/environment.rb @@ -12,7 +12,7 @@ module Gitlab end def to_resource - find_environment || ::Environment.new(attributes) + find_environment || ::Environment.create(attributes) end private diff --git a/spec/lib/gitlab/ci/pipeline/seed/environment_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/environment_spec.rb index 92ad20f30a0..71389999c6e 100644 --- a/spec/lib/gitlab/ci/pipeline/seed/environment_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/seed/environment_spec.rb @@ -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 diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index 4d6269f0e01..fd5f72c4c46 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -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') } |