Commit 12f75815 authored by Tan Le's avatar Tan Le

Reduce database calls on CI Templates specs

This change replaces `let` with `let_it_be` to reduce unnecessary number
of database calls on CI Templates specs. We also replace all instances
of `allow_any_instance_of` stubs with `allow_next_instance_off`
according to the Rubocop lint rules.
parent 8f42da21
...@@ -19,7 +19,7 @@ RSpec.describe 'Jobs/Browser-Performance-Testing.gitlab-ci.yml' do ...@@ -19,7 +19,7 @@ RSpec.describe 'Jobs/Browser-Performance-Testing.gitlab-ci.yml' do
end end
describe 'the created pipeline' do describe 'the created pipeline' do
let(:project) do let_it_be(:project) do
create(:project, :repository, variables: [ create(:project, :repository, variables: [
build(:ci_variable, key: 'CI_KUBERNETES_ACTIVE', value: 'true') build(:ci_variable, key: 'CI_KUBERNETES_ACTIVE', value: 'true')
]) ])
...@@ -35,7 +35,9 @@ RSpec.describe 'Jobs/Browser-Performance-Testing.gitlab-ci.yml' do ...@@ -35,7 +35,9 @@ RSpec.describe 'Jobs/Browser-Performance-Testing.gitlab-ci.yml' do
before do before do
stub_ci_pipeline_yaml_file(template) stub_ci_pipeline_yaml_file(template)
allow_any_instance_of(Ci::BuildScheduleWorker).to receive(:perform).and_return(true) allow_next_instance_of(Ci::BuildScheduleWorker) do |worker|
allow(worker).to receive(:perform).and_return(true)
end
allow(project).to receive(:default_branch).and_return(default_branch) allow(project).to receive(:default_branch).and_return(default_branch)
end end
......
...@@ -22,7 +22,7 @@ RSpec.describe 'Jobs/DAST-Default-Branch-Deploy.gitlab-ci.yml' do ...@@ -22,7 +22,7 @@ RSpec.describe 'Jobs/DAST-Default-Branch-Deploy.gitlab-ci.yml' do
end end
describe 'the created pipeline' do describe 'the created pipeline' do
let(:project) do let_it_be(:project) do
create(:project, :repository, variables: [ create(:project, :repository, variables: [
build(:ci_variable, key: 'CI_KUBERNETES_ACTIVE', value: 'true') build(:ci_variable, key: 'CI_KUBERNETES_ACTIVE', value: 'true')
]) ])
...@@ -37,8 +37,9 @@ RSpec.describe 'Jobs/DAST-Default-Branch-Deploy.gitlab-ci.yml' do ...@@ -37,8 +37,9 @@ RSpec.describe 'Jobs/DAST-Default-Branch-Deploy.gitlab-ci.yml' do
before do before do
stub_ci_pipeline_yaml_file(template) stub_ci_pipeline_yaml_file(template)
allow_next_instance_of(Ci::BuildScheduleWorker) do |worker|
allow_any_instance_of(Ci::BuildScheduleWorker).to receive(:perform).and_return(true) allow(worker).to receive(:perform).and_return(true)
end
allow(project).to receive(:default_branch).and_return(default_branch) allow(project).to receive(:default_branch).and_return(default_branch)
end end
...@@ -53,7 +54,7 @@ RSpec.describe 'Jobs/DAST-Default-Branch-Deploy.gitlab-ci.yml' do ...@@ -53,7 +54,7 @@ RSpec.describe 'Jobs/DAST-Default-Branch-Deploy.gitlab-ci.yml' do
end end
context 'when project has Ultimate license' do context 'when project has Ultimate license' do
let(:license) { create(:license, plan: License::ULTIMATE_PLAN) } let(:license) { build(:license, plan: License::ULTIMATE_PLAN) }
before do before do
allow(License).to receive(:current).and_return(license) allow(License).to receive(:current).and_return(license)
......
...@@ -19,7 +19,7 @@ RSpec.describe 'Jobs/Load-Performance-Testing.gitlab-ci.yml' do ...@@ -19,7 +19,7 @@ RSpec.describe 'Jobs/Load-Performance-Testing.gitlab-ci.yml' do
end end
describe 'the created pipeline' do describe 'the created pipeline' do
let(:project) do let_it_be(:project) do
create(:project, :repository, variables: [ create(:project, :repository, variables: [
build(:ci_variable, key: 'CI_KUBERNETES_ACTIVE', value: 'true') build(:ci_variable, key: 'CI_KUBERNETES_ACTIVE', value: 'true')
]) ])
...@@ -34,8 +34,9 @@ RSpec.describe 'Jobs/Load-Performance-Testing.gitlab-ci.yml' do ...@@ -34,8 +34,9 @@ RSpec.describe 'Jobs/Load-Performance-Testing.gitlab-ci.yml' do
before do before do
stub_ci_pipeline_yaml_file(template) stub_ci_pipeline_yaml_file(template)
allow_next_instance_of(Ci::BuildScheduleWorker) do |worker|
allow_any_instance_of(Ci::BuildScheduleWorker).to receive(:perform).and_return(true) allow(worker).to receive(:perform).and_return(true)
end
allow(project).to receive(:default_branch).and_return(default_branch) allow(project).to receive(:default_branch).and_return(default_branch)
end end
......
...@@ -19,9 +19,9 @@ RSpec.describe 'Verify/Browser-Performance.gitlab-ci.yml' do ...@@ -19,9 +19,9 @@ RSpec.describe 'Verify/Browser-Performance.gitlab-ci.yml' do
end end
describe 'the created pipeline', :clean_gitlab_redis_cache do describe 'the created pipeline', :clean_gitlab_redis_cache do
let(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let(:user) { project.owner }
let(:user) { project.owner }
let(:default_branch) { 'master' } let(:default_branch) { 'master' }
let(:pipeline_ref) { default_branch } let(:pipeline_ref) { default_branch }
let(:service) { Ci::CreatePipelineService.new(project, user, ref: pipeline_ref) } let(:service) { Ci::CreatePipelineService.new(project, user, ref: pipeline_ref) }
...@@ -30,8 +30,9 @@ RSpec.describe 'Verify/Browser-Performance.gitlab-ci.yml' do ...@@ -30,8 +30,9 @@ RSpec.describe 'Verify/Browser-Performance.gitlab-ci.yml' do
before do before do
stub_ci_pipeline_yaml_file(template) stub_ci_pipeline_yaml_file(template)
allow_next_instance_of(Ci::BuildScheduleWorker) do |worker|
allow_any_instance_of(Ci::BuildScheduleWorker).to receive(:perform).and_return(true) allow(worker).to receive(:perform).and_return(true)
end
allow(project).to receive(:default_branch).and_return(default_branch) allow(project).to receive(:default_branch).and_return(default_branch)
end end
......
...@@ -19,9 +19,9 @@ RSpec.describe 'Verify/Load-Performance-Testing.gitlab-ci.yml' do ...@@ -19,9 +19,9 @@ RSpec.describe 'Verify/Load-Performance-Testing.gitlab-ci.yml' do
end end
describe 'the created pipeline', :clean_gitlab_redis_cache do describe 'the created pipeline', :clean_gitlab_redis_cache do
let(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let(:user) { project.owner }
let(:user) { project.owner }
let(:default_branch) { 'master' } let(:default_branch) { 'master' }
let(:pipeline_ref) { default_branch } let(:pipeline_ref) { default_branch }
let(:service) { Ci::CreatePipelineService.new(project, user, ref: pipeline_ref) } let(:service) { Ci::CreatePipelineService.new(project, user, ref: pipeline_ref) }
...@@ -30,8 +30,9 @@ RSpec.describe 'Verify/Load-Performance-Testing.gitlab-ci.yml' do ...@@ -30,8 +30,9 @@ RSpec.describe 'Verify/Load-Performance-Testing.gitlab-ci.yml' do
before do before do
stub_ci_pipeline_yaml_file(template) stub_ci_pipeline_yaml_file(template)
allow_next_instance_of(Ci::BuildScheduleWorker) do |worker|
allow_any_instance_of(Ci::BuildScheduleWorker).to receive(:perform).and_return(true) allow(worker).to receive(:perform).and_return(true)
end
allow(project).to receive(:default_branch).and_return(default_branch) allow(project).to receive(:default_branch).and_return(default_branch)
end end
......
...@@ -18,27 +18,29 @@ RSpec.describe 'API-Fuzzing.gitlab-ci.yml' do ...@@ -18,27 +18,29 @@ RSpec.describe 'API-Fuzzing.gitlab-ci.yml' do
# names between development and production is also quite small making it # names between development and production is also quite small making it
# easy to miss during review. # easy to miss during review.
it 'uses the production repository' do it 'uses the production repository' do
expect( contents.include?(production_registry) ).to be true expect(contents.include?(production_registry)).to be true
end end
it 'doesn\'t use the staging repository' do it 'doesn\'t use the staging repository' do
expect( contents.include?(staging_registry) ).to be false expect(contents.include?(staging_registry)).to be false
end end
end end
describe 'the created pipeline' do describe 'the created pipeline' do
let_it_be(:project) { create(:project, :custom_repo, files: { 'README.txt' => '' }) }
let(:default_branch) { 'master' } let(:default_branch) { 'master' }
let(:pipeline_branch) { default_branch } let(:pipeline_branch) { default_branch }
let(:project) { create(:project, :custom_repo, files: { 'README.txt' => '' }) }
let(:user) { project.owner } let(:user) { project.owner }
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) }
before do before do
stub_ci_pipeline_yaml_file(template.content) stub_ci_pipeline_yaml_file(template.content)
allow_next_instance_of(Ci::BuildScheduleWorker) do |worker|
allow_any_instance_of(Ci::BuildScheduleWorker).to receive(:perform).and_return(true) allow(worker).to receive(:perform).and_return(true)
end
allow(project).to receive(:default_branch).and_return(default_branch) allow(project).to receive(:default_branch).and_return(default_branch)
end end
...@@ -54,7 +56,7 @@ RSpec.describe 'API-Fuzzing.gitlab-ci.yml' do ...@@ -54,7 +56,7 @@ RSpec.describe 'API-Fuzzing.gitlab-ci.yml' do
end end
context 'when project has Ultimate license' do context 'when project has Ultimate license' do
let(:license) { create(:license, plan: License::ULTIMATE_PLAN) } let(:license) { build(:license, plan: License::ULTIMATE_PLAN) }
before do before do
allow(License).to receive(:current).and_return(license) allow(License).to receive(:current).and_return(license)
......
...@@ -20,31 +20,30 @@ RSpec.describe 'API-Fuzzing.latest.gitlab-ci.yml' do ...@@ -20,31 +20,30 @@ RSpec.describe 'API-Fuzzing.latest.gitlab-ci.yml' do
# names between development and production is also quite small making it # names between development and production is also quite small making it
# easy to miss during review. # easy to miss during review.
it 'uses the production repository' do it 'uses the production repository' do
expect( contents.include?(production_registry) ).to be true expect(contents.include?(production_registry)).to be true
end end
it 'doesn\'t use the staging repository' do it 'doesn\'t use the staging repository' do
expect( contents.include?(staging_registry) ).to be false expect(contents.include?(staging_registry)).to be false
end end
end end
describe 'the created pipeline' do describe 'the created pipeline' do
let_it_be(:project) { create(:project, :custom_repo, files: { 'README.txt' => '' }) }
let(:default_branch) { 'master' } let(:default_branch) { 'master' }
let(:pipeline_branch) { default_branch } let(:pipeline_branch) { default_branch }
let(:project) { create(:project, :custom_repo, files: { 'README.txt' => '' }) }
let(:user) { project.owner } let(:user) { project.owner }
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) }
context 'when no stages' do context 'when no stages' do
before do before do
stub_ci_pipeline_yaml_file(template.content) stub_ci_pipeline_yaml_file(template.content)
allow_next_instance_of(Ci::BuildScheduleWorker) do |worker| allow_next_instance_of(Ci::BuildScheduleWorker) do |worker|
allow(worker).to receive(:perform).and_return(true) allow(worker).to receive(:perform).and_return(true)
end end
allow(project).to receive(:default_branch).and_return(default_branch) allow(project).to receive(:default_branch).and_return(default_branch)
end end
...@@ -80,7 +79,7 @@ RSpec.describe 'API-Fuzzing.latest.gitlab-ci.yml' do ...@@ -80,7 +79,7 @@ RSpec.describe 'API-Fuzzing.latest.gitlab-ci.yml' do
end end
context 'when project has Ultimate license' do context 'when project has Ultimate license' do
let(:license) { create(:license, plan: License::ULTIMATE_PLAN) } let(:license) { build(:license, plan: License::ULTIMATE_PLAN) }
before do before do
allow(License).to receive(:current).and_return(license) allow(License).to receive(:current).and_return(license)
......
...@@ -6,8 +6,9 @@ RSpec.describe 'Container-Scanning.gitlab-ci.yml' do ...@@ -6,8 +6,9 @@ RSpec.describe 'Container-Scanning.gitlab-ci.yml' do
subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('Container-Scanning') } subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('Container-Scanning') }
describe 'the created pipeline' do describe 'the created pipeline' do
let_it_be(:project) { create(:project, :custom_repo, files: { 'README.txt' => '' }) }
let(:default_branch) { 'master' } let(:default_branch) { 'master' }
let(:project) { create(:project, :custom_repo, files: { 'README.txt' => '' }) }
let(:user) { project.owner } let(:user) { project.owner }
let(:service) { Ci::CreatePipelineService.new(project, user, ref: 'master' ) } let(:service) { Ci::CreatePipelineService.new(project, user, ref: 'master' ) }
let(:pipeline) { service.execute!(:push) } let(:pipeline) { service.execute!(:push) }
...@@ -15,7 +16,9 @@ RSpec.describe 'Container-Scanning.gitlab-ci.yml' do ...@@ -15,7 +16,9 @@ RSpec.describe 'Container-Scanning.gitlab-ci.yml' do
before do before do
stub_ci_pipeline_yaml_file(template.content) stub_ci_pipeline_yaml_file(template.content)
allow_any_instance_of(Ci::BuildScheduleWorker).to receive(:perform).and_return(true) allow_next_instance_of(Ci::BuildScheduleWorker) do |worker|
allow(worker).to receive(:perform).and_return(true)
end
allow(project).to receive(:default_branch).and_return(default_branch) allow(project).to receive(:default_branch).and_return(default_branch)
end end
...@@ -26,7 +29,7 @@ RSpec.describe 'Container-Scanning.gitlab-ci.yml' do ...@@ -26,7 +29,7 @@ RSpec.describe 'Container-Scanning.gitlab-ci.yml' do
end end
context 'when project has Ultimate license' do context 'when project has Ultimate license' do
let(:license) { create(:license, plan: License::ULTIMATE_PLAN) } let(:license) { build(:license, plan: License::ULTIMATE_PLAN) }
before do before do
allow(License).to receive(:current).and_return(license) allow(License).to receive(:current).and_return(license)
......
...@@ -6,8 +6,9 @@ RSpec.describe 'Coverage-Fuzzing.gitlab-ci.yml' do ...@@ -6,8 +6,9 @@ RSpec.describe 'Coverage-Fuzzing.gitlab-ci.yml' do
subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('Coverage-Fuzzing') } subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('Coverage-Fuzzing') }
describe 'the created pipeline' do describe 'the created pipeline' do
let_it_be(:project) { create(:project, :custom_repo, files: { 'README.txt' => '' }) }
let(:default_branch) { 'master' } let(:default_branch) { 'master' }
let(:project) { create(:project, :custom_repo, files: { 'README.txt' => '' }) }
let(:user) { project.owner } let(:user) { project.owner }
let(:service) { Ci::CreatePipelineService.new(project, user, ref: 'master' ) } let(:service) { Ci::CreatePipelineService.new(project, user, ref: 'master' ) }
let(:pipeline) { service.execute!(:push) } let(:pipeline) { service.execute!(:push) }
...@@ -15,12 +16,14 @@ RSpec.describe 'Coverage-Fuzzing.gitlab-ci.yml' do ...@@ -15,12 +16,14 @@ RSpec.describe 'Coverage-Fuzzing.gitlab-ci.yml' do
before do before do
stub_ci_pipeline_yaml_file(template.content) stub_ci_pipeline_yaml_file(template.content)
allow_any_instance_of(Ci::BuildScheduleWorker).to receive(:perform).and_return(true) allow_next_instance_of(Ci::BuildScheduleWorker) do |worker|
allow(worker).to receive(:perform).and_return(true)
end
allow(project).to receive(:default_branch).and_return(default_branch) allow(project).to receive(:default_branch).and_return(default_branch)
end end
context 'when project has Ultimate license' do context 'when project has Ultimate license' do
let(:license) { create(:license, plan: License::ULTIMATE_PLAN) } let(:license) { build(:license, plan: License::ULTIMATE_PLAN) }
before do before do
allow(License).to receive(:current).and_return(license) allow(License).to receive(:current).and_return(license)
......
...@@ -16,7 +16,9 @@ RSpec.describe 'DAST.gitlab-ci.yml' do ...@@ -16,7 +16,9 @@ RSpec.describe 'DAST.gitlab-ci.yml' do
before do before do
stub_ci_pipeline_yaml_file(template.content) stub_ci_pipeline_yaml_file(template.content)
allow_any_instance_of(Ci::BuildScheduleWorker).to receive(:perform).and_return(true) allow_next_instance_of(Ci::BuildScheduleWorker) do |worker|
allow(worker).to receive(:perform).and_return(true)
end
allow(project).to receive(:default_branch).and_return(default_branch) allow(project).to receive(:default_branch).and_return(default_branch)
end end
...@@ -27,7 +29,7 @@ RSpec.describe 'DAST.gitlab-ci.yml' do ...@@ -27,7 +29,7 @@ RSpec.describe 'DAST.gitlab-ci.yml' do
end end
context 'when project has Ultimate license' do context 'when project has Ultimate license' do
let(:license) { create(:license, plan: License::ULTIMATE_PLAN) } let(:license) { build(:license, plan: License::ULTIMATE_PLAN) }
let(:cluster) { create(:cluster, :project, :provided_by_gcp, projects: [project]) } let(:cluster) { create(:cluster, :project, :provided_by_gcp, projects: [project]) }
before do before do
......
...@@ -74,7 +74,7 @@ RSpec.describe 'DAST.latest.gitlab-ci.yml' do ...@@ -74,7 +74,7 @@ RSpec.describe 'DAST.latest.gitlab-ci.yml' do
end end
context 'when project has Ultimate license' do context 'when project has Ultimate license' do
let(:license) { create(:license, plan: License::ULTIMATE_PLAN) } let(:license) { build(:license, plan: License::ULTIMATE_PLAN) }
before do before do
allow(License).to receive(:current).and_return(license) allow(License).to receive(:current).and_return(license)
...@@ -109,7 +109,7 @@ RSpec.describe 'DAST.latest.gitlab-ci.yml' do ...@@ -109,7 +109,7 @@ RSpec.describe 'DAST.latest.gitlab-ci.yml' do
end end
context 'when project has Ultimate license' do context 'when project has Ultimate license' do
let(:license) { create(:license, plan: License::ULTIMATE_PLAN) } let(:license) { build(:license, plan: License::ULTIMATE_PLAN) }
before do before do
allow(License).to receive(:current).and_return(license) allow(License).to receive(:current).and_return(license)
......
...@@ -10,13 +10,15 @@ RSpec.describe 'Dependency-Scanning.gitlab-ci.yml' do ...@@ -10,13 +10,15 @@ RSpec.describe 'Dependency-Scanning.gitlab-ci.yml' do
let(:files) { { 'README.txt' => '' } } let(:files) { { 'README.txt' => '' } }
let(:project) { create(:project, :custom_repo, files: files) } let(:project) { create(:project, :custom_repo, files: files) }
let(:user) { project.owner } let(:user) { project.owner }
let(:service) { Ci::CreatePipelineService.new(project, user, ref: 'master' ) } let(:service) { Ci::CreatePipelineService.new(project, user, ref: 'master') }
let(:pipeline) { service.execute!(:push) } let(:pipeline) { service.execute!(:push) }
let(:build_names) { pipeline.builds.pluck(:name) } let(:build_names) { pipeline.builds.pluck(:name) }
before do before do
stub_ci_pipeline_yaml_file(template.content) stub_ci_pipeline_yaml_file(template.content)
allow_any_instance_of(Ci::BuildScheduleWorker).to receive(:perform).and_return(true) allow_next_instance_of(Ci::BuildScheduleWorker) do |worker|
allow(worker).to receive(:perform).and_return(true)
end
allow(project).to receive(:default_branch).and_return(default_branch) allow(project).to receive(:default_branch).and_return(default_branch)
end end
...@@ -27,7 +29,7 @@ RSpec.describe 'Dependency-Scanning.gitlab-ci.yml' do ...@@ -27,7 +29,7 @@ RSpec.describe 'Dependency-Scanning.gitlab-ci.yml' do
end end
context 'when project has Ultimate license' do context 'when project has Ultimate license' do
let(:license) { create(:license, plan: License::ULTIMATE_PLAN) } let(:license) { build(:license, plan: License::ULTIMATE_PLAN) }
before do before do
allow(License).to receive(:current).and_return(license) allow(License).to receive(:current).and_return(license)
......
...@@ -6,16 +6,19 @@ RSpec.describe 'License-Scanning.gitlab-ci.yml' do ...@@ -6,16 +6,19 @@ RSpec.describe 'License-Scanning.gitlab-ci.yml' do
subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('License-Scanning') } subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('License-Scanning') }
describe 'the created pipeline' do describe 'the created pipeline' do
let_it_be(:project) { create(:project, :custom_repo, files: { 'README.txt' => '' }) }
let(:default_branch) { 'master' } let(:default_branch) { 'master' }
let(:project) { create(:project, :custom_repo, files: { 'README.txt' => '' }) }
let(:user) { project.owner } let(:user) { project.owner }
let(:service) { Ci::CreatePipelineService.new(project, user, ref: 'master' ) } let(:service) { Ci::CreatePipelineService.new(project, user, ref: 'master') }
let(:pipeline) { service.execute!(:push) } let(:pipeline) { service.execute!(:push) }
let(:build_names) { pipeline.builds.pluck(:name) } let(:build_names) { pipeline.builds.pluck(:name) }
before do before do
stub_ci_pipeline_yaml_file(template.content) stub_ci_pipeline_yaml_file(template.content)
allow_any_instance_of(Ci::BuildScheduleWorker).to receive(:perform).and_return(true) allow_next_instance_of(Ci::BuildScheduleWorker) do |worker|
allow(worker).to receive(:perform).and_return(true)
end
allow(project).to receive(:default_branch).and_return(default_branch) allow(project).to receive(:default_branch).and_return(default_branch)
end end
...@@ -26,7 +29,7 @@ RSpec.describe 'License-Scanning.gitlab-ci.yml' do ...@@ -26,7 +29,7 @@ RSpec.describe 'License-Scanning.gitlab-ci.yml' do
end end
context 'when project has Ultimate license' do context 'when project has Ultimate license' do
let(:license) { create(:license, plan: License::ULTIMATE_PLAN) } let(:license) { build(:license, plan: License::ULTIMATE_PLAN) }
before do before do
allow(License).to receive(:current).and_return(license) allow(License).to receive(:current).and_return(license)
......
...@@ -10,13 +10,15 @@ RSpec.describe 'SAST.gitlab-ci.yml' do ...@@ -10,13 +10,15 @@ RSpec.describe 'SAST.gitlab-ci.yml' do
let(:files) { { 'README.txt' => '' } } let(:files) { { 'README.txt' => '' } }
let(:project) { create(:project, :custom_repo, files: files) } let(:project) { create(:project, :custom_repo, files: files) }
let(:user) { project.owner } let(:user) { project.owner }
let(:service) { Ci::CreatePipelineService.new(project, user, ref: 'master' ) } let(:service) { Ci::CreatePipelineService.new(project, user, ref: 'master') }
let(:pipeline) { service.execute!(:push) } let(:pipeline) { service.execute!(:push) }
let(:build_names) { pipeline.builds.pluck(:name) } let(:build_names) { pipeline.builds.pluck(:name) }
before do before do
stub_ci_pipeline_yaml_file(template.content) stub_ci_pipeline_yaml_file(template.content)
allow_any_instance_of(Ci::BuildScheduleWorker).to receive(:perform).and_return(true) allow_next_instance_of(Ci::BuildScheduleWorker) do |worker|
allow(worker).to receive(:perform).and_return(true)
end
allow(project).to receive(:default_branch).and_return(default_branch) allow(project).to receive(:default_branch).and_return(default_branch)
end end
......
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