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

Fix Rails/SaveBang RuboCop offenses for projects controllers

parent 46106642
......@@ -853,14 +853,7 @@ Style/SymbolProc:
# Configuration parameters: AllowImplicitReturn, AllowedReceivers.
Rails/SaveBang:
Exclude:
- 'ee/spec/controllers/projects/environments_controller_spec.rb'
- 'ee/spec/controllers/projects/issues_controller_spec.rb'
- 'ee/spec/controllers/projects/merge_requests/creations_controller_spec.rb'
- 'ee/spec/controllers/projects/merge_requests_controller_spec.rb'
- 'ee/spec/controllers/projects/project_members_controller_spec.rb'
- 'ee/spec/controllers/projects/service_desk_controller_spec.rb'
- 'ee/spec/controllers/projects/subscriptions_controller_spec.rb'
- 'ee/spec/controllers/projects/vulnerability_feedback_controller_spec.rb'
- 'ee/spec/controllers/subscriptions_controller_spec.rb'
- 'ee/spec/factories/ci/job_artifacts.rb'
- 'ee/spec/factories/epics.rb'
......
---
title: Refactor projects controllers specs to fix SaveBang Cop
merge_request: 36920
author: Rajendra Kadam
type: fixed
......@@ -99,7 +99,7 @@ RSpec.describe Projects::EnvironmentsController do
context 'when user has access to it' do
before do
protected_environment.deploy_access_levels.create(user: user)
protected_environment.deploy_access_levels.create!(user: user)
get :terminal, params: environment_params
end
......
......@@ -184,7 +184,7 @@ RSpec.describe Projects::IssuesController do
before do
sign_in(user)
allow(Gitlab).to receive(:com?).and_return(true)
discussion.update(author: user)
discussion.update!(author: user)
end
shared_context 'non inclusion of gitlab team member badge' do |result|
......
......@@ -32,7 +32,7 @@ RSpec.describe Projects::MergeRequests::CreationsController do
context 'the approvals_before_merge param' do
before do
project.update(approvals_before_merge: 2)
project.update!(approvals_before_merge: 2)
end
context 'when it is less than the one in the target project' do
......@@ -83,8 +83,8 @@ RSpec.describe Projects::MergeRequests::CreationsController do
context 'when the target project is a fork of a deleted project' do
before do
original_project = create(:project)
project.update(forked_from_project: original_project, approvals_before_merge: 4)
original_project.update(pending_delete: true)
project.update!(forked_from_project: original_project, approvals_before_merge: 4)
original_project.update!(pending_delete: true)
create_merge_request(approvals_before_merge: 3)
end
......@@ -105,7 +105,7 @@ RSpec.describe Projects::MergeRequests::CreationsController do
before do
project.add_developer(new_approver)
project.update(disable_overriding_approvers_per_merge_request: disable_overriding_approvers_per_merge_request)
project.update!(disable_overriding_approvers_per_merge_request: disable_overriding_approvers_per_merge_request)
create_merge_request(
approval_rules_attributes: [
......
......@@ -144,7 +144,7 @@ RSpec.describe Projects::MergeRequestsController do
context 'when the merge request requires approval' do
before do
project.update(approvals_before_merge: 1)
project.update!(approvals_before_merge: 1)
end
it_behaves_like 'update invalid issuable', MergeRequest
......@@ -152,12 +152,12 @@ RSpec.describe Projects::MergeRequestsController do
context 'overriding approvers per MR' do
before do
project.update(approvals_before_merge: 1)
project.update!(approvals_before_merge: 1)
end
context 'enabled' do
before do
project.update(disable_overriding_approvers_per_merge_request: false)
project.update!(disable_overriding_approvers_per_merge_request: false)
end
it 'updates approvals' do
......@@ -195,7 +195,7 @@ RSpec.describe Projects::MergeRequestsController do
before do
project.add_developer(new_approver)
project.update(disable_overriding_approvers_per_merge_request: true)
project.update!(disable_overriding_approvers_per_merge_request: true)
end
it 'does not update approvals_before_merge' do
......@@ -364,7 +364,7 @@ RSpec.describe Projects::MergeRequestsController do
before do
upstream.add_developer(user)
upstream.update(approvals_before_merge: 2)
upstream.update!(approvals_before_merge: 2)
end
it_behaves_like 'approvals_before_merge param'
......
......@@ -32,7 +32,7 @@ RSpec.describe Projects::ProjectMembersController do
context 'and the project group has membership lock enabled' do
before do
project.namespace.update(membership_lock: true)
project.namespace.update!(membership_lock: true)
end
it 'responds with 403' do
......@@ -64,7 +64,7 @@ RSpec.describe Projects::ProjectMembersController do
context 'when project group has membership lock enabled' do
before do
project.namespace.update(membership_lock: true)
project.namespace.update!(membership_lock: true)
end
it 'responds with 403' do
......@@ -90,7 +90,7 @@ RSpec.describe Projects::ProjectMembersController do
context 'when project group has membership lock enabled' do
before do
project.namespace.update(membership_lock: true)
project.namespace.update!(membership_lock: true)
end
it 'responds with 403' do
......
......@@ -18,7 +18,7 @@ RSpec.describe Projects::SubscriptionsController do
before do
plan_limits = create(:plan_limits, :default_plan)
plan_limits.update(ci_project_subscriptions: 2)
plan_limits.update!(ci_project_subscriptions: 2)
end
context 'when user is authorized' do
......@@ -80,7 +80,7 @@ RSpec.describe Projects::SubscriptionsController do
context 'when project is not public' do
before do
upstream_project.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
upstream_project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
end
it 'does not create a new subscription' do
......
......@@ -52,7 +52,7 @@ RSpec.describe Projects::VulnerabilityFeedbackController do
pipeline: create(:ci_pipeline)
)
feedback.save(validate: false)
feedback.save!(validate: false)
end
it 'ignores feedback in other project' 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