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