Commit 31898f3c authored by Mark Chao's avatar Mark Chao

Merge branch '331906_fix_tests_for_templates' into 'master'

Update tests for templates to support default branch

See merge request gitlab-org/gitlab!65266
parents 90b2ce17 923b06fc
...@@ -6,7 +6,7 @@ RSpec.describe 'DAST.gitlab-ci.yml' do ...@@ -6,7 +6,7 @@ RSpec.describe 'DAST.gitlab-ci.yml' do
subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('DAST') } subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('DAST') }
describe 'the created pipeline' do describe 'the created pipeline' do
let(:default_branch) { 'master' } let(:default_branch) { project.default_branch_or_main }
let(:pipeline_branch) { default_branch } let(:pipeline_branch) { default_branch }
let(:project) { create(:project, :custom_repo, files: { 'README.txt' => '' }) } let(:project) { create(:project, :custom_repo, files: { 'README.txt' => '' }) }
let(:user) { project.owner } let(:user) { project.owner }
...@@ -107,7 +107,7 @@ RSpec.describe 'DAST.gitlab-ci.yml' do ...@@ -107,7 +107,7 @@ RSpec.describe 'DAST.gitlab-ci.yml' do
let(:pipeline_branch) { 'patch-1' } let(:pipeline_branch) { 'patch-1' }
before do before do
project.repository.create_branch(pipeline_branch) project.repository.create_branch(pipeline_branch, default_branch)
end end
it 'includes dast job' do it 'includes dast job' do
...@@ -133,7 +133,7 @@ RSpec.describe 'DAST.gitlab-ci.yml' do ...@@ -133,7 +133,7 @@ RSpec.describe 'DAST.gitlab-ci.yml' do
let(:pipeline_branch) { 'patch-1' } let(:pipeline_branch) { 'patch-1' }
before do before do
project.repository.create_branch(pipeline_branch) project.repository.create_branch(pipeline_branch, default_branch)
end end
it 'includes no jobs' do it 'includes no jobs' do
......
...@@ -18,7 +18,7 @@ RSpec.describe 'DAST.latest.gitlab-ci.yml' do ...@@ -18,7 +18,7 @@ RSpec.describe 'DAST.latest.gitlab-ci.yml' do
subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('DAST.latest') } subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('DAST.latest') }
describe 'the created pipeline' do describe 'the created pipeline' do
let(:default_branch) { 'master' } let(:default_branch) { project.default_branch_or_main }
let(:pipeline_branch) { default_branch } let(:pipeline_branch) { default_branch }
let(:project) { create(:project, :custom_repo, files: { 'README.txt' => '' }) } let(:project) { create(:project, :custom_repo, files: { 'README.txt' => '' }) }
let(:user) { project.owner } let(:user) { project.owner }
...@@ -143,7 +143,7 @@ RSpec.describe 'DAST.latest.gitlab-ci.yml' do ...@@ -143,7 +143,7 @@ RSpec.describe 'DAST.latest.gitlab-ci.yml' do
let(:pipeline_branch) { 'patch-1' } let(:pipeline_branch) { 'patch-1' }
before do before do
project.repository.create_branch(pipeline_branch) project.repository.create_branch(pipeline_branch, default_branch)
end end
it 'includes dast job' do it 'includes dast job' do
...@@ -167,7 +167,7 @@ RSpec.describe 'DAST.latest.gitlab-ci.yml' do ...@@ -167,7 +167,7 @@ RSpec.describe 'DAST.latest.gitlab-ci.yml' do
let(:pipeline_branch) { 'patch-1' } let(:pipeline_branch) { 'patch-1' }
before do before do
project.repository.create_branch(pipeline_branch) project.repository.create_branch(pipeline_branch, default_branch)
end end
include_examples 'includes no jobs' include_examples 'includes no jobs'
......
...@@ -6,7 +6,7 @@ RSpec.describe 'Deploy-ECS.gitlab-ci.yml' do ...@@ -6,7 +6,7 @@ RSpec.describe 'Deploy-ECS.gitlab-ci.yml' do
subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('AWS/Deploy-ECS') } subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('AWS/Deploy-ECS') }
describe 'the created pipeline' do describe 'the created pipeline' do
let(:default_branch) { 'master' } let(:default_branch) { project.default_branch_or_main }
let(:pipeline_branch) { default_branch } let(:pipeline_branch) { default_branch }
let(:project) { create(:project, :auto_devops, :custom_repo, files: { 'README.md' => '' }) } let(:project) { create(:project, :auto_devops, :custom_repo, files: { 'README.md' => '' }) }
let(:user) { project.owner } let(:user) { project.owner }
...@@ -38,7 +38,7 @@ RSpec.describe 'Deploy-ECS.gitlab-ci.yml' do ...@@ -38,7 +38,7 @@ RSpec.describe 'Deploy-ECS.gitlab-ci.yml' do
let(:pipeline_branch) { 'test_branch' } let(:pipeline_branch) { 'test_branch' }
before do before do
project.repository.create_branch(pipeline_branch) project.repository.create_branch(pipeline_branch, default_branch)
end end
it_behaves_like 'no pipeline yaml error' it_behaves_like 'no pipeline yaml error'
......
...@@ -12,7 +12,8 @@ RSpec.describe 'Managed-Cluster-Applications.gitlab-ci.yml' do ...@@ -12,7 +12,8 @@ RSpec.describe 'Managed-Cluster-Applications.gitlab-ci.yml' do
let(:service) { Ci::CreatePipelineService.new(project, user, ref: pipeline_branch ) } let(:service) { Ci::CreatePipelineService.new(project, user, ref: pipeline_branch ) }
let(:pipeline) { service.execute!(:push) } let(:pipeline) { service.execute!(:push) }
let(:build_names) { pipeline.builds.pluck(:name) } let(:build_names) { pipeline.builds.pluck(:name) }
let(:pipeline_branch) { 'master' } let(:default_branch) { project.default_branch_or_main }
let(:pipeline_branch) { default_branch }
before do before do
stub_ci_pipeline_yaml_file(template.content) stub_ci_pipeline_yaml_file(template.content)
...@@ -28,7 +29,7 @@ RSpec.describe 'Managed-Cluster-Applications.gitlab-ci.yml' do ...@@ -28,7 +29,7 @@ RSpec.describe 'Managed-Cluster-Applications.gitlab-ci.yml' do
let(:pipeline_branch) { 'a_branch' } let(:pipeline_branch) { 'a_branch' }
before do before do
project.repository.create_branch(pipeline_branch) project.repository.create_branch(pipeline_branch, default_branch)
end end
it 'has no jobs' do it 'has no jobs' do
......
...@@ -10,7 +10,7 @@ RSpec.describe 'Terraform.latest.gitlab-ci.yml' do ...@@ -10,7 +10,7 @@ RSpec.describe 'Terraform.latest.gitlab-ci.yml' do
subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('Terraform.latest') } subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('Terraform.latest') }
describe 'the created pipeline' do describe 'the created pipeline' do
let(:default_branch) { 'master' } let(:default_branch) { project.default_branch_or_main }
let(:pipeline_branch) { default_branch } let(:pipeline_branch) { default_branch }
let(:project) { create(:project, :custom_repo, files: { 'README.md' => '' }) } let(:project) { create(:project, :custom_repo, files: { 'README.md' => '' }) }
let(:user) { project.owner } let(:user) { project.owner }
...@@ -34,7 +34,7 @@ RSpec.describe 'Terraform.latest.gitlab-ci.yml' do ...@@ -34,7 +34,7 @@ RSpec.describe 'Terraform.latest.gitlab-ci.yml' do
let(:pipeline_branch) { 'patch-1' } let(:pipeline_branch) { 'patch-1' }
before do before do
project.repository.create_branch(pipeline_branch) project.repository.create_branch(pipeline_branch, default_branch)
end end
it 'does not creates a deploy and a test job' do it 'does not creates a deploy and a test job' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment