Commit e902e7a0 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'rails-save-bang-7' into 'master'

Fix rubocop offenses for ee/spec/finders/* and spec/finders/*

See merge request gitlab-org/gitlab!38173
parents dfaf09e8 24f236d6
...@@ -1246,8 +1246,6 @@ Rails/SaveBang: ...@@ -1246,8 +1246,6 @@ Rails/SaveBang:
Exclude: Exclude:
- 'ee/spec/controllers/projects/merge_requests_controller_spec.rb' - 'ee/spec/controllers/projects/merge_requests_controller_spec.rb'
- 'ee/spec/controllers/subscriptions_controller_spec.rb' - 'ee/spec/controllers/subscriptions_controller_spec.rb'
- 'ee/spec/finders/epics_finder_spec.rb'
- 'ee/spec/finders/security/vulnerabilities_finder_spec.rb'
- 'ee/spec/frontend/fixtures/analytics.rb' - 'ee/spec/frontend/fixtures/analytics.rb'
- 'ee/spec/graphql/resolvers/vulnerabilities_resolver_spec.rb' - 'ee/spec/graphql/resolvers/vulnerabilities_resolver_spec.rb'
- 'ee/spec/initializers/fog_google_https_private_urls_spec.rb' - 'ee/spec/initializers/fog_google_https_private_urls_spec.rb'
...@@ -1524,17 +1522,6 @@ Rails/SaveBang: ...@@ -1524,17 +1522,6 @@ Rails/SaveBang:
- 'spec/features/security/project/public_access_spec.rb' - 'spec/features/security/project/public_access_spec.rb'
- 'spec/features/users/login_spec.rb' - 'spec/features/users/login_spec.rb'
- 'spec/features/users/show_spec.rb' - 'spec/features/users/show_spec.rb'
- 'spec/finders/admin/projects_finder_spec.rb'
- 'spec/finders/autocomplete/move_to_project_finder_spec.rb'
- 'spec/finders/ci/pipelines_for_merge_request_finder_spec.rb'
- 'spec/finders/group_descendants_finder_spec.rb'
- 'spec/finders/group_projects_finder_spec.rb'
- 'spec/finders/issues_finder_spec.rb'
- 'spec/finders/joined_groups_finder_spec.rb'
- 'spec/finders/merge_requests_finder_spec.rb'
- 'spec/finders/personal_projects_finder_spec.rb'
- 'spec/finders/projects_finder_spec.rb'
- 'spec/finders/uploader_finder_spec.rb'
- 'spec/frontend/fixtures/issues.rb' - 'spec/frontend/fixtures/issues.rb'
- 'spec/frontend/fixtures/merge_requests.rb' - 'spec/frontend/fixtures/merge_requests.rb'
- 'spec/graphql/mutations/merge_requests/set_locked_spec.rb' - 'spec/graphql/mutations/merge_requests/set_locked_spec.rb'
......
---
title: Refactor spec/finders and ee/spec/finders to fix SaveBang Cop
merge_request: 38173
author: Rajendra Kadam
type: fixed
...@@ -215,8 +215,8 @@ RSpec.describe EpicsFinder do ...@@ -215,8 +215,8 @@ RSpec.describe EpicsFinder do
context 'by parent' do context 'by parent' do
before do before do
epic2.update(parent: epic1) epic2.update!(parent: epic1)
epic3.update(parent: epic2) epic3.update!(parent: epic2)
end end
it 'returns direct children of the parent' do it 'returns direct children of the parent' do
......
...@@ -74,7 +74,7 @@ RSpec.describe Security::VulnerabilitiesFinder do ...@@ -74,7 +74,7 @@ RSpec.describe Security::VulnerabilitiesFinder do
let(:vulnerable) { group } let(:vulnerable) { group }
before do before do
project.update(namespace: group) project.update!(namespace: group)
end end
it 'only returns vulnerabilities matching the given projects' do it 'only returns vulnerabilities matching the given projects' do
......
...@@ -88,7 +88,7 @@ RSpec.describe Admin::ProjectsFinder do ...@@ -88,7 +88,7 @@ RSpec.describe Admin::ProjectsFinder do
context 'filter by abandoned' do context 'filter by abandoned' do
before do before do
private_project.update(last_activity_at: Time.zone.now - 6.months - 1.minute) private_project.update!(last_activity_at: Time.zone.now - 6.months - 1.minute)
end end
let(:params) { { abandoned: true } } let(:params) { { abandoned: true } }
...@@ -98,7 +98,7 @@ RSpec.describe Admin::ProjectsFinder do ...@@ -98,7 +98,7 @@ RSpec.describe Admin::ProjectsFinder do
context 'filter by last_repository_check_failed' do context 'filter by last_repository_check_failed' do
before do before do
private_project.update(last_repository_check_failed: true) private_project.update!(last_repository_check_failed: true)
end end
let(:params) { { last_repository_check_failed: true } } let(:params) { { last_repository_check_failed: true } }
......
...@@ -53,7 +53,7 @@ RSpec.describe Autocomplete::MoveToProjectFinder do ...@@ -53,7 +53,7 @@ RSpec.describe Autocomplete::MoveToProjectFinder do
it 'does not return projects for which issues are disabled' do it 'does not return projects for which issues are disabled' do
reporter_project.add_reporter(user) reporter_project.add_reporter(user)
reporter_project.update(issues_enabled: false) reporter_project.update!(issues_enabled: false)
other_reporter_project = create(:project) other_reporter_project = create(:project)
other_reporter_project.add_reporter(user) other_reporter_project.add_reporter(user)
......
...@@ -115,7 +115,7 @@ RSpec.describe Ci::PipelinesForMergeRequestFinder do ...@@ -115,7 +115,7 @@ RSpec.describe Ci::PipelinesForMergeRequestFinder do
context 'with multiple irrelevant merge_request_diffs' do context 'with multiple irrelevant merge_request_diffs' do
before do before do
merge_request.update(target_branch: 'v1.0.0') merge_request.update!(target_branch: 'v1.0.0')
end end
it_behaves_like 'returning pipelines with proper ordering' it_behaves_like 'returning pipelines with proper ordering'
......
...@@ -122,7 +122,7 @@ RSpec.describe GroupDescendantsFinder do ...@@ -122,7 +122,7 @@ RSpec.describe GroupDescendantsFinder do
it 'does not include projects shared with the group' do it 'does not include projects shared with the group' do
project = create(:project, namespace: group) project = create(:project, namespace: group)
other_project = create(:project) other_project = create(:project)
other_project.project_group_links.create(group: group, other_project.project_group_links.create!(group: group,
group_access: Gitlab::Access::MAINTAINER) group_access: Gitlab::Access::MAINTAINER)
expect(finder.execute).to contain_exactly(project) expect(finder.execute).to contain_exactly(project)
......
...@@ -51,7 +51,7 @@ RSpec.describe GroupProjectsFinder do ...@@ -51,7 +51,7 @@ RSpec.describe GroupProjectsFinder do
let!(:shared_project_4) { create(:project, :internal, path: '8') } let!(:shared_project_4) { create(:project, :internal, path: '8') }
before do before do
shared_project_4.project_group_links.create(group_access: Gitlab::Access::REPORTER, group: group) shared_project_4.project_group_links.create!(group_access: Gitlab::Access::REPORTER, group: group)
end end
let(:params) { { min_access_level: Gitlab::Access::MAINTAINER } } let(:params) { { min_access_level: Gitlab::Access::MAINTAINER } }
...@@ -76,7 +76,7 @@ RSpec.describe GroupProjectsFinder do ...@@ -76,7 +76,7 @@ RSpec.describe GroupProjectsFinder do
context "with external user" do context "with external user" do
before do before do
current_user.update(external: true) current_user.update!(external: true)
end end
it { is_expected.to match_array([shared_project_2, shared_project_1]) } it { is_expected.to match_array([shared_project_2, shared_project_1]) }
...@@ -107,7 +107,7 @@ RSpec.describe GroupProjectsFinder do ...@@ -107,7 +107,7 @@ RSpec.describe GroupProjectsFinder do
context "with external user" do context "with external user" do
before do before do
current_user.update(external: true) current_user.update!(external: true)
end end
context 'with subgroups projects' do context 'with subgroups projects' do
......
...@@ -185,9 +185,9 @@ RSpec.describe IssuesFinder do ...@@ -185,9 +185,9 @@ RSpec.describe IssuesFinder do
let(:params) { { milestone_title: group_milestone.title } } let(:params) { { milestone_title: group_milestone.title } }
before do before do
project2.update(namespace: group) project2.update!(namespace: group)
issue2.update(milestone: group_milestone) issue2.update!(milestone: group_milestone)
issue3.update(milestone: group_milestone) issue3.update!(milestone: group_milestone)
end end
it 'returns issues assigned to that group milestone' do it 'returns issues assigned to that group milestone' do
......
...@@ -55,7 +55,7 @@ RSpec.describe JoinedGroupsFinder do ...@@ -55,7 +55,7 @@ RSpec.describe JoinedGroupsFinder do
context 'external users' do context 'external users' do
before do before do
profile_visitor.update(external: true) profile_visitor.update!(external: true)
end end
context 'if not a member' do context 'if not a member' do
......
...@@ -335,9 +335,8 @@ RSpec.describe MergeRequestsFinder do ...@@ -335,9 +335,8 @@ RSpec.describe MergeRequestsFinder do
let(:group_milestone) { create(:milestone, group: group) } let(:group_milestone) { create(:milestone, group: group) }
before do before do
project2.update(namespace: group) merge_request1.update!(milestone: group_milestone)
merge_request2.update(milestone: group_milestone) merge_request2.update!(milestone: group_milestone)
merge_request3.update(milestone: group_milestone)
end end
it 'returns merge requests assigned to that group milestone' do it 'returns merge requests assigned to that group milestone' do
...@@ -345,7 +344,7 @@ RSpec.describe MergeRequestsFinder do ...@@ -345,7 +344,7 @@ RSpec.describe MergeRequestsFinder do
merge_requests = described_class.new(user, params).execute merge_requests = described_class.new(user, params).execute
expect(merge_requests).to contain_exactly(merge_request2, merge_request3) expect(merge_requests).to contain_exactly(merge_request1, merge_request2)
end end
context 'using NOT' do context 'using NOT' do
...@@ -354,7 +353,7 @@ RSpec.describe MergeRequestsFinder do ...@@ -354,7 +353,7 @@ RSpec.describe MergeRequestsFinder do
it 'returns MRs not assigned to that group milestone' do it 'returns MRs not assigned to that group milestone' do
merge_requests = described_class.new(user, params).execute merge_requests = described_class.new(user, params).execute
expect(merge_requests).to contain_exactly(merge_request1, merge_request4, merge_request5) expect(merge_requests).to contain_exactly(merge_request3, merge_request4, merge_request5)
end end
end end
end end
......
...@@ -37,7 +37,7 @@ RSpec.describe PersonalProjectsFinder do ...@@ -37,7 +37,7 @@ RSpec.describe PersonalProjectsFinder do
context 'external' do context 'external' do
before do before do
current_user.update(external: true) current_user.update!(external: true)
end end
it { is_expected.to eq([public_project, private_project]) } it { is_expected.to eq([public_project, private_project]) }
......
...@@ -244,8 +244,8 @@ RSpec.describe ProjectsFinder, :do_not_mock_admin_mode do ...@@ -244,8 +244,8 @@ RSpec.describe ProjectsFinder, :do_not_mock_admin_mode do
let(:params) { { last_activity_after: 60.minutes.ago } } let(:params) { { last_activity_after: 60.minutes.ago } }
before do before do
internal_project.update(last_activity_at: Time.now) internal_project.update!(last_activity_at: Time.now)
public_project.update(last_activity_at: 61.minutes.ago) public_project.update!(last_activity_at: 61.minutes.ago)
end end
it { is_expected.to match_array([internal_project]) } it { is_expected.to match_array([internal_project]) }
...@@ -255,8 +255,8 @@ RSpec.describe ProjectsFinder, :do_not_mock_admin_mode do ...@@ -255,8 +255,8 @@ RSpec.describe ProjectsFinder, :do_not_mock_admin_mode do
let(:params) { { last_activity_before: 60.minutes.ago } } let(:params) { { last_activity_before: 60.minutes.ago } }
before do before do
internal_project.update(last_activity_at: Time.now) internal_project.update!(last_activity_at: Time.now)
public_project.update(last_activity_at: 61.minutes.ago) public_project.update!(last_activity_at: 61.minutes.ago)
end end
it { is_expected.to match_array([public_project]) } it { is_expected.to match_array([public_project]) }
......
...@@ -12,7 +12,7 @@ RSpec.describe UploaderFinder do ...@@ -12,7 +12,7 @@ RSpec.describe UploaderFinder do
subject { described_class.new(project, secret, file_name).execute } subject { described_class.new(project, secret, file_name).execute }
before do before do
upload.save upload.save!
end end
context 'when successful' do context 'when successful' do
...@@ -32,7 +32,7 @@ RSpec.describe UploaderFinder do ...@@ -32,7 +32,7 @@ RSpec.describe UploaderFinder do
context 'when path traversal in file name' do context 'when path traversal in file name' do
before do before do
upload.path = '/uploads/11111111111111111111111111111111/../../../../../../../../../../../../../../etc/passwd)' upload.path = '/uploads/11111111111111111111111111111111/../../../../../../../../../../../../../../etc/passwd)'
upload.save upload.save!
end end
it 'returns nil' do it 'returns nil' 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