Commit 4c0d56ac authored by Rajendra Kadam's avatar Rajendra Kadam Committed by Peter Leitzen

Fix Rails/SaveBang offenses for spec/services/ci/*

Fixes Rails/SaveBang cop for spec files
parent b2eb27d3
...@@ -763,9 +763,6 @@ Rails/SaveBang: ...@@ -763,9 +763,6 @@ Rails/SaveBang:
- 'ee/spec/requests/lfs_http_spec.rb' - 'ee/spec/requests/lfs_http_spec.rb'
- 'ee/spec/services/approval_rules/finalize_service_spec.rb' - 'ee/spec/services/approval_rules/finalize_service_spec.rb'
- 'ee/spec/services/approval_rules/update_service_spec.rb' - 'ee/spec/services/approval_rules/update_service_spec.rb'
- 'ee/spec/services/ci/minutes/email_notification_service_spec.rb'
- 'ee/spec/services/ci/process_build_service_spec.rb'
- 'ee/spec/services/ci/register_job_service_spec.rb'
- 'ee/spec/services/ee/boards/issues/create_service_spec.rb' - 'ee/spec/services/ee/boards/issues/create_service_spec.rb'
- 'ee/spec/services/ee/boards/issues/list_service_spec.rb' - 'ee/spec/services/ee/boards/issues/list_service_spec.rb'
- 'ee/spec/services/ee/boards/lists/list_service_spec.rb' - 'ee/spec/services/ee/boards/lists/list_service_spec.rb'
...@@ -1152,11 +1149,6 @@ Rails/SaveBang: ...@@ -1152,11 +1149,6 @@ Rails/SaveBang:
- 'spec/services/auth/container_registry_authentication_service_spec.rb' - 'spec/services/auth/container_registry_authentication_service_spec.rb'
- 'spec/services/auto_merge/base_service_spec.rb' - 'spec/services/auto_merge/base_service_spec.rb'
- 'spec/services/auto_merge_service_spec.rb' - 'spec/services/auto_merge_service_spec.rb'
- 'spec/services/ci/create_cross_project_pipeline_service_spec.rb'
- 'spec/services/ci/create_pipeline_service_spec.rb'
- 'spec/services/ci/register_job_service_spec.rb'
- 'spec/services/ci/retry_build_service_spec.rb'
- 'spec/services/ci/update_runner_service_spec.rb'
- 'spec/services/clusters/update_service_spec.rb' - 'spec/services/clusters/update_service_spec.rb'
- 'spec/services/deployments/after_create_service_spec.rb' - 'spec/services/deployments/after_create_service_spec.rb'
- 'spec/services/design_management/generate_image_versions_service_spec.rb' - 'spec/services/design_management/generate_image_versions_service_spec.rb'
......
---
title: Fix Rails/SaveBang offenses for */spec/services/ci/*
merge_request: 41317
author: Rajendra Kadam
type: other
...@@ -42,7 +42,7 @@ RSpec.describe Ci::Minutes::EmailNotificationService do ...@@ -42,7 +42,7 @@ RSpec.describe Ci::Minutes::EmailNotificationService do
context 'with a personal namespace' do context 'with a personal namespace' do
before do before do
namespace.update(owner_id: user.id) namespace.update!(owner_id: user.id)
end end
it_behaves_like 'namespace with available CI minutes' do it_behaves_like 'namespace with available CI minutes' do
......
...@@ -45,7 +45,7 @@ RSpec.describe Ci::ProcessBuildService, '#execute' do ...@@ -45,7 +45,7 @@ RSpec.describe Ci::ProcessBuildService, '#execute' do
context 'when user has access to the environment' do context 'when user has access to the environment' do
before do before do
protected_environment.deploy_access_levels.create(user: user) protected_environment.deploy_access_levels.create!(user: user)
end end
it 'enqueues the build' do it 'enqueues the build' do
......
...@@ -13,7 +13,7 @@ RSpec.describe Ci::RegisterJobService do ...@@ -13,7 +13,7 @@ RSpec.describe Ci::RegisterJobService do
subject { described_class.new(shared_runner).execute } subject { described_class.new(shared_runner).execute }
before do before do
project.update(shared_runners_enabled: false) project.update!(shared_runners_enabled: false)
end end
it 'result is valid if replica did caught-up' do it 'result is valid if replica did caught-up' do
...@@ -73,7 +73,7 @@ RSpec.describe Ci::RegisterJobService do ...@@ -73,7 +73,7 @@ RSpec.describe Ci::RegisterJobService do
context 'and project is public' do context 'and project is public' do
context 'and public projects cost factor is 0 (default)' do context 'and public projects cost factor is 0 (default)' do
before do before do
project.update(visibility_level: Project::PUBLIC) project.update!(visibility_level: Project::PUBLIC)
end end
it_behaves_like 'returns a build', 11 it_behaves_like 'returns a build', 11
...@@ -81,8 +81,8 @@ RSpec.describe Ci::RegisterJobService do ...@@ -81,8 +81,8 @@ RSpec.describe Ci::RegisterJobService do
context 'and public projects cost factor is > 0' do context 'and public projects cost factor is > 0' do
before do before do
project.update(visibility_level: Project::PUBLIC) project.update!(visibility_level: Project::PUBLIC)
shared_runner.update(public_projects_minutes_cost_factor: 1.1) shared_runner.update!(public_projects_minutes_cost_factor: 1.1)
end end
it_behaves_like 'does not return a build', 11 it_behaves_like 'does not return a build', 11
...@@ -92,7 +92,7 @@ RSpec.describe Ci::RegisterJobService do ...@@ -92,7 +92,7 @@ RSpec.describe Ci::RegisterJobService do
context 'and extra shared runners minutes purchased' do context 'and extra shared runners minutes purchased' do
before do before do
project.namespace.update(extra_shared_runners_minutes_limit: 10) project.namespace.update!(extra_shared_runners_minutes_limit: 10)
end end
context 'and usage is below the combined limit' do context 'and usage is below the combined limit' do
...@@ -107,12 +107,12 @@ RSpec.describe Ci::RegisterJobService do ...@@ -107,12 +107,12 @@ RSpec.describe Ci::RegisterJobService do
context 'when limit set at namespace level' do context 'when limit set at namespace level' do
before do before do
project.namespace.update(shared_runners_minutes_limit: 5) project.namespace.update!(shared_runners_minutes_limit: 5)
end end
context 'and limit set to unlimited' do context 'and limit set to unlimited' do
before do before do
project.namespace.update(shared_runners_minutes_limit: 0) project.namespace.update!(shared_runners_minutes_limit: 0)
end end
it_behaves_like 'returns a build', 10 it_behaves_like 'returns a build', 10
...@@ -128,7 +128,7 @@ RSpec.describe Ci::RegisterJobService do ...@@ -128,7 +128,7 @@ RSpec.describe Ci::RegisterJobService do
context 'and extra shared runners minutes purchased' do context 'and extra shared runners minutes purchased' do
before do before do
project.namespace.update(extra_shared_runners_minutes_limit: 5) project.namespace.update!(extra_shared_runners_minutes_limit: 5)
end end
context 'and usage is below the combined limit' do context 'and usage is below the combined limit' do
...@@ -145,7 +145,7 @@ RSpec.describe Ci::RegisterJobService do ...@@ -145,7 +145,7 @@ RSpec.describe Ci::RegisterJobService do
context 'and namespace limit lower than global limit' do context 'and namespace limit lower than global limit' do
before do before do
stub_application_setting(shared_runners_minutes: 10) stub_application_setting(shared_runners_minutes: 10)
project.namespace.update(shared_runners_minutes_limit: 5) project.namespace.update!(shared_runners_minutes_limit: 5)
end end
it_behaves_like 'does not return a build', 6 it_behaves_like 'does not return a build', 6
...@@ -154,7 +154,7 @@ RSpec.describe Ci::RegisterJobService do ...@@ -154,7 +154,7 @@ RSpec.describe Ci::RegisterJobService do
context 'and namespace limit higher than global limit' do context 'and namespace limit higher than global limit' do
before do before do
stub_application_setting(shared_runners_minutes: 5) stub_application_setting(shared_runners_minutes: 5)
project.namespace.update(shared_runners_minutes_limit: 10) project.namespace.update!(shared_runners_minutes_limit: 10)
end end
it_behaves_like 'returns a build', 6 it_behaves_like 'returns a build', 6
...@@ -168,7 +168,7 @@ RSpec.describe Ci::RegisterJobService do ...@@ -168,7 +168,7 @@ RSpec.describe Ci::RegisterJobService do
context 'and usage below the limit on root namespace' do context 'and usage below the limit on root namespace' do
before do before do
root_ancestor.update(shared_runners_minutes_limit: 10) root_ancestor.update!(shared_runners_minutes_limit: 10)
end end
it_behaves_like 'returns a build', 9 it_behaves_like 'returns a build', 9
...@@ -177,9 +177,9 @@ RSpec.describe Ci::RegisterJobService do ...@@ -177,9 +177,9 @@ RSpec.describe Ci::RegisterJobService do
context 'and usage above the limit on root namespace' do context 'and usage above the limit on root namespace' do
before do before do
# limit is ignored on subnamespace # limit is ignored on subnamespace
group.update(shared_runners_minutes_limit: 20) group.update_columns(shared_runners_minutes_limit: 20)
root_ancestor.update(shared_runners_minutes_limit: 10) root_ancestor.update!(shared_runners_minutes_limit: 10)
root_ancestor.create_namespace_statistics( root_ancestor.create_namespace_statistics(
shared_runners_seconds: 60 * 11) shared_runners_seconds: 60 * 11)
end end
......
...@@ -223,7 +223,7 @@ RSpec.describe Ci::CreatePipelineService do ...@@ -223,7 +223,7 @@ RSpec.describe Ci::CreatePipelineService do
context 'auto-cancel enabled' do context 'auto-cancel enabled' do
before do before do
project.update(auto_cancel_pending_pipelines: 'enabled') project.update!(auto_cancel_pending_pipelines: 'enabled')
end end
it 'does not cancel HEAD pipeline' do it 'does not cancel HEAD pipeline' do
...@@ -248,7 +248,7 @@ RSpec.describe Ci::CreatePipelineService do ...@@ -248,7 +248,7 @@ RSpec.describe Ci::CreatePipelineService do
end end
it 'cancel created outdated pipelines', :sidekiq_might_not_need_inline do it 'cancel created outdated pipelines', :sidekiq_might_not_need_inline do
pipeline_on_previous_commit.update(status: 'created') pipeline_on_previous_commit.update!(status: 'created')
pipeline pipeline
expect(pipeline_on_previous_commit.reload).to have_attributes(status: 'canceled', auto_canceled_by_id: pipeline.id) expect(pipeline_on_previous_commit.reload).to have_attributes(status: 'canceled', auto_canceled_by_id: pipeline.id)
...@@ -439,7 +439,7 @@ RSpec.describe Ci::CreatePipelineService do ...@@ -439,7 +439,7 @@ RSpec.describe Ci::CreatePipelineService do
context 'auto-cancel disabled' do context 'auto-cancel disabled' do
before do before do
project.update(auto_cancel_pending_pipelines: 'disabled') project.update!(auto_cancel_pending_pipelines: 'disabled')
end end
it 'does not auto cancel pending non-HEAD pipelines' do it 'does not auto cancel pending non-HEAD pipelines' do
......
...@@ -15,14 +15,14 @@ module Ci ...@@ -15,14 +15,14 @@ module Ci
describe '#execute' do describe '#execute' do
context 'runner follow tag list' do context 'runner follow tag list' do
it "picks build with the same tag" do it "picks build with the same tag" do
pending_job.update(tag_list: ["linux"]) pending_job.update!(tag_list: ["linux"])
specific_runner.update(tag_list: ["linux"]) specific_runner.update!(tag_list: ["linux"])
expect(execute(specific_runner)).to eq(pending_job) expect(execute(specific_runner)).to eq(pending_job)
end end
it "does not pick build with different tag" do it "does not pick build with different tag" do
pending_job.update(tag_list: ["linux"]) pending_job.update!(tag_list: ["linux"])
specific_runner.update(tag_list: ["win32"]) specific_runner.update!(tag_list: ["win32"])
expect(execute(specific_runner)).to be_falsey expect(execute(specific_runner)).to be_falsey
end end
...@@ -31,24 +31,24 @@ module Ci ...@@ -31,24 +31,24 @@ module Ci
end end
it "does not pick build with tag" do it "does not pick build with tag" do
pending_job.update(tag_list: ["linux"]) pending_job.update!(tag_list: ["linux"])
expect(execute(specific_runner)).to be_falsey expect(execute(specific_runner)).to be_falsey
end end
it "pick build without tag" do it "pick build without tag" do
specific_runner.update(tag_list: ["win32"]) specific_runner.update!(tag_list: ["win32"])
expect(execute(specific_runner)).to eq(pending_job) expect(execute(specific_runner)).to eq(pending_job)
end end
end end
context 'deleted projects' do context 'deleted projects' do
before do before do
project.update(pending_delete: true) project.update!(pending_delete: true)
end end
context 'for shared runners' do context 'for shared runners' do
before do before do
project.update(shared_runners_enabled: true) project.update!(shared_runners_enabled: true)
end end
it 'does not pick a build' do it 'does not pick a build' do
...@@ -65,7 +65,7 @@ module Ci ...@@ -65,7 +65,7 @@ module Ci
context 'allow shared runners' do context 'allow shared runners' do
before do before do
project.update(shared_runners_enabled: true) project.update!(shared_runners_enabled: true)
end end
context 'for multiple builds' do context 'for multiple builds' do
...@@ -131,7 +131,7 @@ module Ci ...@@ -131,7 +131,7 @@ module Ci
context 'disallow shared runners' do context 'disallow shared runners' do
before do before do
project.update(shared_runners_enabled: false) project.update!(shared_runners_enabled: false)
end end
context 'shared runner' do context 'shared runner' do
...@@ -152,7 +152,7 @@ module Ci ...@@ -152,7 +152,7 @@ module Ci
context 'disallow when builds are disabled' do context 'disallow when builds are disabled' do
before do before do
project.update(shared_runners_enabled: true, group_runners_enabled: true) project.update!(shared_runners_enabled: true, group_runners_enabled: true)
project.project_feature.update_attribute(:builds_access_level, ProjectFeature::DISABLED) project.project_feature.update_attribute(:builds_access_level, ProjectFeature::DISABLED)
end end
...@@ -591,8 +591,8 @@ module Ci ...@@ -591,8 +591,8 @@ module Ci
.with(:job_queue_duration_seconds, anything, anything, anything) .with(:job_queue_duration_seconds, anything, anything, anything)
.and_return(job_queue_duration_seconds) .and_return(job_queue_duration_seconds)
project.update(shared_runners_enabled: true) project.update!(shared_runners_enabled: true)
pending_job.update(created_at: current_time - 3600, queued_at: current_time - 1800) pending_job.update!(created_at: current_time - 3600, queued_at: current_time - 1800)
end end
shared_examples 'attempt counter collector' do shared_examples 'attempt counter collector' do
...@@ -661,7 +661,7 @@ module Ci ...@@ -661,7 +661,7 @@ module Ci
context 'when pending job with queued_at=nil is used' do context 'when pending job with queued_at=nil is used' do
before do before do
pending_job.update(queued_at: nil) pending_job.update!(queued_at: nil)
end end
it_behaves_like 'attempt counter collector' it_behaves_like 'attempt counter collector'
......
...@@ -70,7 +70,7 @@ RSpec.describe Ci::RetryBuildService do ...@@ -70,7 +70,7 @@ RSpec.describe Ci::RetryBuildService do
# Make sure that build has both `stage_id` and `stage` because FactoryBot # Make sure that build has both `stage_id` and `stage` because FactoryBot
# can reset one of the fields when assigning another. We plan to deprecate # can reset one of the fields when assigning another. We plan to deprecate
# and remove legacy `stage` column in the future. # and remove legacy `stage` column in the future.
build.update(stage: 'test', stage_id: stage.id) build.update!(stage: 'test', stage_id: stage.id)
# Make sure we have one instance for every possible job_artifact_X # Make sure we have one instance for every possible job_artifact_X
# associations to check they are correctly rejected on build duplication. # associations to check they are correctly rejected on build duplication.
......
...@@ -50,7 +50,7 @@ RSpec.describe Ci::UpdateRunnerService do ...@@ -50,7 +50,7 @@ RSpec.describe Ci::UpdateRunnerService do
end end
def update def update
described_class.new(runner).update(params) described_class.new(runner).update(params) # rubocop: disable Rails/SaveBang
end end
end end
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