Commit 6aa28c22 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'rails-save-bang-project-controllers' into 'master'

Fix Rails/SaveBang offenses for spec/controllers/projects

See merge request gitlab-org/gitlab!57643
parents 1f0a21f6 38b31444
......@@ -189,22 +189,6 @@ Rails/SaveBang:
- 'spec/controllers/omniauth_callbacks_controller_spec.rb'
- 'spec/controllers/profiles/emails_controller_spec.rb'
- 'spec/controllers/profiles/notifications_controller_spec.rb'
- 'spec/controllers/projects/artifacts_controller_spec.rb'
- 'spec/controllers/projects/cycle_analytics/events_controller_spec.rb'
- 'spec/controllers/projects/cycle_analytics_controller_spec.rb'
- 'spec/controllers/projects/discussions_controller_spec.rb'
- 'spec/controllers/projects/forks_controller_spec.rb'
- 'spec/controllers/projects/group_links_controller_spec.rb'
- 'spec/controllers/projects/imports_controller_spec.rb'
- 'spec/controllers/projects/issues_controller_spec.rb'
- 'spec/controllers/projects/labels_controller_spec.rb'
- 'spec/controllers/projects/milestones_controller_spec.rb'
- 'spec/controllers/projects/notes_controller_spec.rb'
- 'spec/controllers/projects/pipelines_controller_spec.rb'
- 'spec/controllers/projects/releases/evidences_controller_spec.rb'
- 'spec/controllers/projects/runners_controller_spec.rb'
- 'spec/controllers/projects/starrers_controller_spec.rb'
- 'spec/controllers/projects/uploads_controller_spec.rb'
- 'spec/controllers/projects_controller_spec.rb'
- 'spec/controllers/sent_notifications_controller_spec.rb'
- 'spec/controllers/sessions_controller_spec.rb'
......
---
title: Fix Rails/SaveBang rubocop offenses in spec/controllers/projects/*
merge_request: 57643
author: Abdul Wadood @abdulwd
type: fixed
......@@ -448,7 +448,7 @@ RSpec.describe Projects::ArtifactsController do
context 'with regular branch' do
before do
pipeline.update(ref: 'master',
pipeline.update!(ref: 'master',
sha: project.commit('master').sha)
get :latest_succeeded, params: params_from_ref('master')
......@@ -459,7 +459,7 @@ RSpec.describe Projects::ArtifactsController do
context 'with branch name containing slash' do
before do
pipeline.update(ref: 'improve/awesome',
pipeline.update!(ref: 'improve/awesome',
sha: project.commit('improve/awesome').sha)
get :latest_succeeded, params: params_from_ref('improve/awesome')
......@@ -470,7 +470,7 @@ RSpec.describe Projects::ArtifactsController do
context 'with branch name and path containing slashes' do
before do
pipeline.update(ref: 'improve/awesome',
pipeline.update!(ref: 'improve/awesome',
sha: project.commit('improve/awesome').sha)
get :latest_succeeded, params: params_from_ref('improve/awesome', job.name, 'file/README.md')
......
......@@ -26,7 +26,7 @@ RSpec.describe Projects::CycleAnalytics::EventsController do
let(:issue) { create(:issue, project: project, created_at: 9.days.ago) }
before do
issue.update(milestone: milestone)
issue.update!(milestone: milestone)
end
it 'is not empty' do
......
......@@ -85,7 +85,7 @@ RSpec.describe Projects::DiscussionsController do
context "when the discussion is not resolvable" do
before do
note.update(system: true)
note.update!(system: true)
end
it "returns status 404" do
......@@ -168,7 +168,7 @@ RSpec.describe Projects::DiscussionsController do
context "when the discussion is not resolvable" do
before do
note.update(system: true)
note.update!(system: true)
end
it "returns status 404" do
......
......@@ -71,7 +71,7 @@ RSpec.describe Projects::ForksController do
context 'when fork is internal' do
before do
forked_project.update(visibility_level: Project::INTERNAL, group: group)
forked_project.update!(visibility_level: Project::INTERNAL, group: group)
end
it 'forks counts are correct' do
......@@ -86,7 +86,7 @@ RSpec.describe Projects::ForksController do
context 'when fork is private' do
before do
forked_project.update(visibility_level: Project::PRIVATE, group: group)
forked_project.update!(visibility_level: Project::PRIVATE, group: group)
end
shared_examples 'forks counts' do
......
......@@ -31,7 +31,7 @@ RSpec.describe Projects::GroupLinksController do
context 'when project is not allowed to be shared with a group' do
before do
group.update(share_with_group_lock: false)
group.update!(share_with_group_lock: false)
end
include_context 'link project to group'
......
......@@ -47,7 +47,7 @@ RSpec.describe Projects::ImportsController do
context 'when import is in progress' do
before do
import_state.update(status: :started)
import_state.update!(status: :started)
end
it 'renders template' do
......@@ -65,7 +65,7 @@ RSpec.describe Projects::ImportsController do
context 'when import failed' do
before do
import_state.update(status: :failed)
import_state.update!(status: :failed)
end
it 'redirects to new_namespace_project_import_path' do
......@@ -77,7 +77,7 @@ RSpec.describe Projects::ImportsController do
context 'when import finished' do
before do
import_state.update(status: :finished)
import_state.update!(status: :finished)
end
context 'when project is a fork' do
......@@ -126,7 +126,7 @@ RSpec.describe Projects::ImportsController do
context 'when import never happened' do
before do
import_state.update(status: :none)
import_state.update!(status: :none)
end
it 'redirects to namespace_project_path' do
......
......@@ -44,7 +44,7 @@ RSpec.describe Projects::IssuesController do
let_it_be(:issue) { create(:issue, project: new_project) }
before do
project.route.destroy
project.route.destroy!
new_project.redirect_routes.create!(path: project.full_path)
new_project.add_developer(user)
end
......@@ -711,7 +711,7 @@ RSpec.describe Projects::IssuesController do
issue.update!(last_edited_by: deleted_user, last_edited_at: Time.current)
deleted_user.destroy
deleted_user.destroy!
sign_in(user)
end
......@@ -1064,10 +1064,10 @@ RSpec.describe Projects::IssuesController do
labels = create_list(:label, 10, project: project).map(&:to_reference)
issue = create(:issue, project: project, description: 'Test issue')
control_count = ActiveRecord::QueryRecorder.new { issue.update(description: [issue.description, label].join(' ')) }.count
control_count = ActiveRecord::QueryRecorder.new { issue.update!(description: [issue.description, label].join(' ')) }.count
# Follow-up to get rid of this `2 * label.count` requirement: https://gitlab.com/gitlab-org/gitlab-foss/issues/52230
expect { issue.update(description: [issue.description, labels].join(' ')) }
expect { issue.update!(description: [issue.description, labels].join(' ')) }
.not_to exceed_query_limit(control_count + 2 * labels.count)
end
......@@ -1923,7 +1923,7 @@ RSpec.describe Projects::IssuesController do
before do
sign_in(user)
project.route.destroy
project.route.destroy!
new_project.redirect_routes.create!(path: project.full_path)
new_project.add_developer(user)
end
......
......@@ -65,7 +65,7 @@ RSpec.describe Projects::LabelsController do
end
it 'does not include group labels when project does not belong to a group' do
project.update(namespace: create(:namespace))
project.update!(namespace: create(:namespace))
list_labels
......@@ -221,7 +221,7 @@ RSpec.describe Projects::LabelsController do
end
context 'when requesting a redirected path' do
let_it_be(:redirect_route) { project.redirect_routes.create(path: project.full_path + 'old') }
let_it_be(:redirect_route) { project.redirect_routes.create!(path: project.full_path + 'old') }
it 'redirects to the canonical path' do
get :index, params: { namespace_id: project.namespace, project_id: project.to_param + 'old' }
......@@ -267,7 +267,7 @@ RSpec.describe Projects::LabelsController do
end
context 'when requesting a redirected path' do
let_it_be(:redirect_route) { project.redirect_routes.create(path: project.full_path + 'old') }
let_it_be(:redirect_route) { project.redirect_routes.create!(path: project.full_path + 'old') }
it 'returns not found' do
post :generate, params: { namespace_id: project.namespace, project_id: project.to_param + 'old' }
......
......@@ -105,7 +105,7 @@ RSpec.describe Projects::MilestonesController do
context 'with a single group ancestor' do
before do
project.update(namespace: group)
project.update!(namespace: group)
get :index, params: { namespace_id: project.namespace.id, project_id: project.id }, format: :json
end
......@@ -122,7 +122,7 @@ RSpec.describe Projects::MilestonesController do
let!(:subgroup_milestone) { create(:milestone, group: subgroup) }
before do
project.update(namespace: subgroup)
project.update!(namespace: subgroup)
get :index, params: { namespace_id: project.namespace.id, project_id: project.id }, format: :json
end
......@@ -158,7 +158,7 @@ RSpec.describe Projects::MilestonesController do
let(:group) { create(:group) }
before do
project.update(namespace: group)
project.update!(namespace: group)
end
context 'when user does not have permission to promote milestone' do
......@@ -234,7 +234,7 @@ RSpec.describe Projects::MilestonesController do
end
it 'renders 404' do
project.update(namespace: user.namespace)
project.update!(namespace: user.namespace)
post :promote, params: { namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid }
......@@ -253,7 +253,7 @@ RSpec.describe Projects::MilestonesController do
before do
project.add_guest(guest_user)
sign_in(guest_user)
issue.update(assignee_ids: issue_assignee.id)
issue.update!(assignee_ids: issue_assignee.id)
end
context "when issue is not confidential" do
......@@ -269,7 +269,7 @@ RSpec.describe Projects::MilestonesController do
context "when issue is confidential" do
before do
issue.update(confidential: true)
issue.update!(confidential: true)
end
it 'shows no milestone participants' do
......
......@@ -334,7 +334,7 @@ RSpec.describe Projects::NotesController do
before do
project.update_attribute(:visibility_level, project_visibility)
project.project_feature.update(merge_requests_access_level: merge_requests_access_level)
project.project_feature.update!(merge_requests_access_level: merge_requests_access_level)
sign_in(user)
end
......@@ -917,7 +917,7 @@ RSpec.describe Projects::NotesController do
context "when the note is not resolvable" do
before do
note.update(system: true)
note.update!(system: true)
end
it "returns status 404" do
......@@ -980,7 +980,7 @@ RSpec.describe Projects::NotesController do
context "when the note is not resolvable" do
before do
note.update(system: true)
note.update!(system: true)
end
it "returns status 404" do
......
......@@ -13,7 +13,7 @@ RSpec.describe Projects::PipelinesController do
allow(Sidekiq.logger).to receive(:info)
stub_not_protect_default_branch
project.add_developer(user)
project.project_feature.update(builds_access_level: feature)
project.project_feature.update!(builds_access_level: feature)
sign_in(user)
end
......@@ -702,7 +702,7 @@ RSpec.describe Projects::PipelinesController do
before do
project.add_developer(user)
project.project_feature.update(builds_access_level: feature)
project.project_feature.update!(builds_access_level: feature)
end
context 'with a valid .gitlab-ci.yml file' do
......@@ -777,7 +777,7 @@ RSpec.describe Projects::PipelinesController do
before do
project.add_developer(user)
project.project_feature.update(builds_access_level: feature)
project.project_feature.update!(builds_access_level: feature)
end
context 'with a valid .gitlab-ci.yml file' do
......
......@@ -62,7 +62,7 @@ RSpec.describe Projects::Releases::EvidencesController do
context 'when the release was created before evidence existed' do
before do
evidence.destroy
evidence.destroy!
end
it_behaves_like 'not found'
......
......@@ -46,7 +46,7 @@ RSpec.describe Projects::RunnersController do
describe '#resume' do
it 'marks the runner as active and ticks the queue' do
runner.update(active: false)
runner.update!(active: false)
expect do
post :resume, params: params
......@@ -61,7 +61,7 @@ RSpec.describe Projects::RunnersController do
describe '#pause' do
it 'marks the runner as inactive and ticks the queue' do
runner.update(active: true)
runner.update!(active: true)
expect do
post :pause, params: params
......
......@@ -170,7 +170,7 @@ RSpec.describe Projects::StarrersController do
context 'when project is private' do
before do
project.update(visibility_level: Project::PRIVATE)
project.update!(visibility_level: Project::PRIVATE)
end
it 'starrers are not visible for non logged in users' do
......
......@@ -29,7 +29,7 @@ RSpec.describe Projects::UploadsController do
let!(:upload) { create(:upload, :issuable_upload, :with_file, model: model) }
let(:project) { model }
let(:upload_path) { File.basename(upload.path) }
let!(:redirect_route) { project.redirect_routes.create(path: project.full_path + 'old') }
let!(:redirect_route) { project.redirect_routes.create!(path: project.full_path + 'old') }
it 'redirects to a file with the proper extension' do
get :show, params: { namespace_id: project.namespace, project_id: project.to_param + 'old', filename: File.basename(upload.path), secret: upload.secret }
......
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