Commit 923b06fc authored by Vasilii Iakliushin's avatar Vasilii Iakliushin

Update tests for templates to support default branch

Contributes to https://gitlab.com/gitlab-org/gitlab/-/issues/331906
parent f363da8a
......@@ -6,7 +6,7 @@ RSpec.describe 'DAST.gitlab-ci.yml' do
subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('DAST') }
describe 'the created pipeline' do
let(:default_branch) { 'master' }
let(:default_branch) { project.default_branch_or_main }
let(:pipeline_branch) { default_branch }
let(:project) { create(:project, :custom_repo, files: { 'README.txt' => '' }) }
let(:user) { project.owner }
......@@ -107,7 +107,7 @@ RSpec.describe 'DAST.gitlab-ci.yml' do
let(:pipeline_branch) { 'patch-1' }
before do
project.repository.create_branch(pipeline_branch)
project.repository.create_branch(pipeline_branch, default_branch)
end
it 'includes dast job' do
......@@ -133,7 +133,7 @@ RSpec.describe 'DAST.gitlab-ci.yml' do
let(:pipeline_branch) { 'patch-1' }
before do
project.repository.create_branch(pipeline_branch)
project.repository.create_branch(pipeline_branch, default_branch)
end
it 'includes no jobs' do
......
......@@ -18,7 +18,7 @@ RSpec.describe 'DAST.latest.gitlab-ci.yml' do
subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('DAST.latest') }
describe 'the created pipeline' do
let(:default_branch) { 'master' }
let(:default_branch) { project.default_branch_or_main }
let(:pipeline_branch) { default_branch }
let(:project) { create(:project, :custom_repo, files: { 'README.txt' => '' }) }
let(:user) { project.owner }
......@@ -143,7 +143,7 @@ RSpec.describe 'DAST.latest.gitlab-ci.yml' do
let(:pipeline_branch) { 'patch-1' }
before do
project.repository.create_branch(pipeline_branch)
project.repository.create_branch(pipeline_branch, default_branch)
end
it 'includes dast job' do
......@@ -167,7 +167,7 @@ RSpec.describe 'DAST.latest.gitlab-ci.yml' do
let(:pipeline_branch) { 'patch-1' }
before do
project.repository.create_branch(pipeline_branch)
project.repository.create_branch(pipeline_branch, default_branch)
end
include_examples 'includes no jobs'
......
......@@ -6,7 +6,7 @@ RSpec.describe 'Deploy-ECS.gitlab-ci.yml' do
subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('AWS/Deploy-ECS') }
describe 'the created pipeline' do
let(:default_branch) { 'master' }
let(:default_branch) { project.default_branch_or_main }
let(:pipeline_branch) { default_branch }
let(:project) { create(:project, :auto_devops, :custom_repo, files: { 'README.md' => '' }) }
let(:user) { project.owner }
......@@ -38,7 +38,7 @@ RSpec.describe 'Deploy-ECS.gitlab-ci.yml' do
let(:pipeline_branch) { 'test_branch' }
before do
project.repository.create_branch(pipeline_branch)
project.repository.create_branch(pipeline_branch, default_branch)
end
it_behaves_like 'no pipeline yaml error'
......
......@@ -12,7 +12,8 @@ RSpec.describe 'Managed-Cluster-Applications.gitlab-ci.yml' do
let(:service) { Ci::CreatePipelineService.new(project, user, ref: pipeline_branch ) }
let(:pipeline) { service.execute!(:push) }
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
stub_ci_pipeline_yaml_file(template.content)
......@@ -28,7 +29,7 @@ RSpec.describe 'Managed-Cluster-Applications.gitlab-ci.yml' do
let(:pipeline_branch) { 'a_branch' }
before do
project.repository.create_branch(pipeline_branch)
project.repository.create_branch(pipeline_branch, default_branch)
end
it 'has no jobs' do
......
......@@ -10,7 +10,7 @@ RSpec.describe 'Terraform.latest.gitlab-ci.yml' do
subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('Terraform.latest') }
describe 'the created pipeline' do
let(:default_branch) { 'master' }
let(:default_branch) { project.default_branch_or_main }
let(:pipeline_branch) { default_branch }
let(:project) { create(:project, :custom_repo, files: { 'README.md' => '' }) }
let(:user) { project.owner }
......@@ -34,7 +34,7 @@ RSpec.describe 'Terraform.latest.gitlab-ci.yml' do
let(:pipeline_branch) { 'patch-1' }
before do
project.repository.create_branch(pipeline_branch)
project.repository.create_branch(pipeline_branch, default_branch)
end
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