Commit 64aaa8ee authored by Rajendra Kadam's avatar Rajendra Kadam Committed by Rémy Coutable

Fix SaveBang offenses for ee/spec/lib/ee/gitlab/background_migration/*

Fixes Rails/SaveBang cop for spec files
parent bba75738
...@@ -697,11 +697,6 @@ Rails/SaveBang: ...@@ -697,11 +697,6 @@ Rails/SaveBang:
- 'ee/spec/initializers/fog_google_https_private_urls_spec.rb' - 'ee/spec/initializers/fog_google_https_private_urls_spec.rb'
- 'ee/spec/lib/analytics/merge_request_metrics_calculator_spec.rb' - 'ee/spec/lib/analytics/merge_request_metrics_calculator_spec.rb'
- 'ee/spec/lib/ee/gitlab/auth/ldap/sync/group_spec.rb' - 'ee/spec/lib/ee/gitlab/auth/ldap/sync/group_spec.rb'
- 'ee/spec/lib/ee/gitlab/background_migration/migrate_approver_to_approval_rules_spec.rb'
- 'ee/spec/lib/ee/gitlab/background_migration/move_epic_issues_after_epics_spec.rb'
- 'ee/spec/lib/ee/gitlab/background_migration/populate_any_approval_rule_for_merge_requests_spec.rb'
- 'ee/spec/lib/ee/gitlab/background_migration/populate_any_approval_rule_for_projects_spec.rb'
- 'ee/spec/lib/ee/gitlab/background_migration/prune_orphaned_geo_events_spec.rb'
- 'ee/spec/lib/ee/gitlab/checks/push_rules/commit_check_spec.rb' - 'ee/spec/lib/ee/gitlab/checks/push_rules/commit_check_spec.rb'
- 'ee/spec/lib/ee/gitlab/ci/pipeline/quota/activity_spec.rb' - 'ee/spec/lib/ee/gitlab/ci/pipeline/quota/activity_spec.rb'
- 'ee/spec/lib/gitlab/auth/ldap/access_spec.rb' - 'ee/spec/lib/gitlab/auth/ldap/access_spec.rb'
......
---
title: Fix Rails/SaveBang offenses for ee/spec/lib/ee/gitlab/background_migration/*
merge_request: 41357
author: Rajendra Kadam
type: fixed
...@@ -157,8 +157,8 @@ RSpec.describe Gitlab::BackgroundMigration::MigrateApproverToApprovalRules do ...@@ -157,8 +157,8 @@ RSpec.describe Gitlab::BackgroundMigration::MigrateApproverToApprovalRules do
context 'when approvals_before_merge is nil' do context 'when approvals_before_merge is nil' do
it "updates with project's approvals_required" do it "updates with project's approvals_required" do
target.target_project.update(approvals_before_merge: 3) target.target_project.update!(approvals_before_merge: 3)
target.update(approvals_before_merge: nil) target.update!(approvals_before_merge: nil)
create_member_in(create(:user), :old_schema) create_member_in(create(:user), :old_schema)
described_class.new.perform(target_type, target.id) described_class.new.perform(target_type, target.id)
...@@ -169,8 +169,8 @@ RSpec.describe Gitlab::BackgroundMigration::MigrateApproverToApprovalRules do ...@@ -169,8 +169,8 @@ RSpec.describe Gitlab::BackgroundMigration::MigrateApproverToApprovalRules do
context 'when approvals_before_merge is too big' do context 'when approvals_before_merge is too big' do
it "caps at allowed maximum" do it "caps at allowed maximum" do
target.target_project.update(approvals_before_merge: ::ApprovalRuleLike::APPROVALS_REQUIRED_MAX + 1) target.target_project.update!(approvals_before_merge: ::ApprovalRuleLike::APPROVALS_REQUIRED_MAX + 1)
target.update(approvals_before_merge: nil) target.update!(approvals_before_merge: nil)
create_member_in(create(:user), :old_schema) create_member_in(create(:user), :old_schema)
described_class.new.perform(target_type, target.id) described_class.new.perform(target_type, target.id)
...@@ -272,7 +272,7 @@ RSpec.describe Gitlab::BackgroundMigration::MigrateApproverToApprovalRules do ...@@ -272,7 +272,7 @@ RSpec.describe Gitlab::BackgroundMigration::MigrateApproverToApprovalRules do
let(:target_type) { 'Project' } let(:target_type) { 'Project' }
it "does not err" do it "does not err" do
target.destroy target.destroy!
expect do expect do
described_class.new.perform(target_type, target.id) described_class.new.perform(target_type, target.id)
......
...@@ -31,21 +31,21 @@ RSpec.describe Gitlab::BackgroundMigration::MoveEpicIssuesAfterEpics, schema: 20 ...@@ -31,21 +31,21 @@ RSpec.describe Gitlab::BackgroundMigration::MoveEpicIssuesAfterEpics, schema: 20
} }
end end
let(:user) { users.create(name: 'test', email: 'test@example.com', projects_limit: 5) } let(:user) { users.create!(name: 'test', email: 'test@example.com', projects_limit: 5) }
let(:group) { namespaces.create(name: 'gitlab', path: 'gitlab-org') } let(:group) { namespaces.create!(name: 'gitlab', path: 'gitlab-org') }
context 'when there are epic_issues present' do context 'when there are epic_issues present' do
let(:project) { projects.create(namespace_id: group.id, name: 'foo') } let(:project) { projects.create!(namespace_id: group.id, name: 'foo') }
let(:base_epic) { epics.create(epic_params.merge(iid: 3, relative_position: 500)) } let(:base_epic) { epics.create!(epic_params.merge(iid: 3, relative_position: 500)) }
let(:issue_1) { issues.create(issue_params.merge(iid: 1)) } let(:issue_1) { issues.create!(issue_params.merge(iid: 1)) }
let(:issue_2) { issues.create(issue_params.merge(iid: 2)) } let(:issue_2) { issues.create!(issue_params.merge(iid: 2)) }
let(:issue_3) { issues.create(issue_params.merge(iid: 3)) } let(:issue_3) { issues.create!(issue_params.merge(iid: 3)) }
let!(:epic_1) { epics.create(epic_params.merge(iid: 1, relative_position: 100)) } let!(:epic_1) { epics.create!(epic_params.merge(iid: 1, relative_position: 100)) }
let!(:epic_2) { epics.create(epic_params.merge(iid: 2, relative_position: 5000)) } let!(:epic_2) { epics.create!(epic_params.merge(iid: 2, relative_position: 5000)) }
let!(:epic_issue_1) { epic_issues.create(issue_id: issue_1.id, epic_id: base_epic.id, relative_position: 400) } let!(:epic_issue_1) { epic_issues.create!(issue_id: issue_1.id, epic_id: base_epic.id, relative_position: 400) }
let!(:epic_issue_2) { epic_issues.create(issue_id: issue_2.id, epic_id: base_epic.id, relative_position: 5010) } let!(:epic_issue_2) { epic_issues.create!(issue_id: issue_2.id, epic_id: base_epic.id, relative_position: 5010) }
let!(:epic_issue_3) { epic_issues.create(issue_id: issue_3.id, epic_id: base_epic.id, relative_position: Gitlab::Database::MAX_INT_VALUE - 10) } let!(:epic_issue_3) { epic_issues.create!(issue_id: issue_3.id, epic_id: base_epic.id, relative_position: Gitlab::Database::MAX_INT_VALUE - 10) }
before do before do
subject.perform(epics.first.id, epics.last.id) subject.perform(epics.first.id, epics.last.id)
...@@ -79,7 +79,7 @@ RSpec.describe Gitlab::BackgroundMigration::MoveEpicIssuesAfterEpics, schema: 20 ...@@ -79,7 +79,7 @@ RSpec.describe Gitlab::BackgroundMigration::MoveEpicIssuesAfterEpics, schema: 20
context 'when there are no epic_issues' do context 'when there are no epic_issues' do
it 'runs correctly' do it 'runs correctly' do
epics.create(epic_params.merge(iid: 3, relative_position: 500)) epics.create!(epic_params.merge(iid: 3, relative_position: 500))
expect(subject.perform(1, 10)).to be_zero expect(subject.perform(1, 10)).to be_zero
end end
......
...@@ -4,9 +4,9 @@ require 'spec_helper' ...@@ -4,9 +4,9 @@ require 'spec_helper'
RSpec.describe Gitlab::BackgroundMigration::PopulateAnyApprovalRuleForMergeRequests, schema: 2019_09_05_091831 do RSpec.describe Gitlab::BackgroundMigration::PopulateAnyApprovalRuleForMergeRequests, schema: 2019_09_05_091831 do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') } let(:namespace) { namespaces.create!(name: 'gitlab', path: 'gitlab-org') }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:project) { projects.create(namespace_id: namespace.id, name: 'foo') } let(:project) { projects.create!(namespace_id: namespace.id, name: 'foo') }
let(:merge_requests) { table(:merge_requests) } let(:merge_requests) { table(:merge_requests) }
let(:approval_merge_request_rules) { table(:approval_merge_request_rules) } let(:approval_merge_request_rules) { table(:approval_merge_request_rules) }
...@@ -18,7 +18,7 @@ RSpec.describe Gitlab::BackgroundMigration::PopulateAnyApprovalRuleForMergeReque ...@@ -18,7 +18,7 @@ RSpec.describe Gitlab::BackgroundMigration::PopulateAnyApprovalRuleForMergeReque
source_branch: 'mr name', source_branch: 'mr name',
title: "mr name#{id}") title: "mr name#{id}")
merge_requests.create(params) merge_requests.create!(params)
end end
before do before do
...@@ -29,12 +29,12 @@ RSpec.describe Gitlab::BackgroundMigration::PopulateAnyApprovalRuleForMergeReque ...@@ -29,12 +29,12 @@ RSpec.describe Gitlab::BackgroundMigration::PopulateAnyApprovalRuleForMergeReque
# Test filtering already migrated rows # Test filtering already migrated rows
create_merge_request(4, approvals_before_merge: 3) create_merge_request(4, approvals_before_merge: 3)
approval_merge_request_rules.create(id: 4, approval_merge_request_rules.create!(id: 4,
merge_request_id: 4, approvals_required: 3, rule_type: 4, name: ApprovalRuleLike::ALL_MEMBERS) merge_request_id: 4, approvals_required: 3, rule_type: 4, name: ApprovalRuleLike::ALL_MEMBERS)
# Test filtering MRs with existing rules # Test filtering MRs with existing rules
create_merge_request(5, approvals_before_merge: 3) create_merge_request(5, approvals_before_merge: 3)
approval_merge_request_rules.create(id: 5, approval_merge_request_rules.create!(id: 5,
merge_request_id: 5, approvals_required: 3, rule_type: 1, name: 'Regular rules') merge_request_id: 5, approvals_required: 3, rule_type: 1, name: 'Regular rules')
create_merge_request(6, approvals_before_merge: 5) create_merge_request(6, approvals_before_merge: 5)
......
...@@ -4,14 +4,14 @@ require 'spec_helper' ...@@ -4,14 +4,14 @@ require 'spec_helper'
RSpec.describe Gitlab::BackgroundMigration::PopulateAnyApprovalRuleForProjects, schema: 2019_09_05_091812 do RSpec.describe Gitlab::BackgroundMigration::PopulateAnyApprovalRuleForProjects, schema: 2019_09_05_091812 do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') } let(:namespace) { namespaces.create!(name: 'gitlab', path: 'gitlab-org') }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:approval_project_rules) { table(:approval_project_rules) } let(:approval_project_rules) { table(:approval_project_rules) }
def create_project(id, params = {}) def create_project(id, params = {})
params.merge!(id: id, namespace_id: namespace.id) params.merge!(id: id, namespace_id: namespace.id)
projects.create(params) projects.create!(params)
end end
before do before do
...@@ -22,7 +22,7 @@ RSpec.describe Gitlab::BackgroundMigration::PopulateAnyApprovalRuleForProjects, ...@@ -22,7 +22,7 @@ RSpec.describe Gitlab::BackgroundMigration::PopulateAnyApprovalRuleForProjects,
# Test filtering already migrated rows # Test filtering already migrated rows
project_with_any_approver_rule = create_project(4, approvals_before_merge: 3) project_with_any_approver_rule = create_project(4, approvals_before_merge: 3)
approval_project_rules.create(id: 4, approval_project_rules.create!(id: 4,
project_id: project_with_any_approver_rule.id, project_id: project_with_any_approver_rule.id,
approvals_required: 3, approvals_required: 3,
rule_type: ApprovalProjectRule.rule_types[:any_approver], rule_type: ApprovalProjectRule.rule_types[:any_approver],
...@@ -30,7 +30,7 @@ RSpec.describe Gitlab::BackgroundMigration::PopulateAnyApprovalRuleForProjects, ...@@ -30,7 +30,7 @@ RSpec.describe Gitlab::BackgroundMigration::PopulateAnyApprovalRuleForProjects,
# Test filtering MRs with existing rules # Test filtering MRs with existing rules
project_with_regular_rule = create_project(5, approvals_before_merge: 3) project_with_regular_rule = create_project(5, approvals_before_merge: 3)
approval_project_rules.create(id: 5, approval_project_rules.create!(id: 5,
project_id: project_with_regular_rule.id, project_id: project_with_regular_rule.id,
approvals_required: 3, approvals_required: 3,
rule_type: ApprovalProjectRule.rule_types[:regular], rule_type: ApprovalProjectRule.rule_types[:regular],
......
...@@ -6,8 +6,8 @@ RSpec.describe Gitlab::BackgroundMigration::PruneOrphanedGeoEvents, geo: false, ...@@ -6,8 +6,8 @@ RSpec.describe Gitlab::BackgroundMigration::PruneOrphanedGeoEvents, geo: false,
let(:event_table_name) { 'geo_repository_updated_events' } let(:event_table_name) { 'geo_repository_updated_events' }
let(:geo_event_log) { table(:geo_event_log) } let(:geo_event_log) { table(:geo_event_log) }
let(:geo_updated_events) { table(event_table_name) } let(:geo_updated_events) { table(event_table_name) }
let(:namespace) { table(:namespaces).create(name: 'foo', path: 'foo') } let(:namespace) { table(:namespaces).create!(name: 'foo', path: 'foo') }
let(:project) { table(:projects).create(name: 'bar', path: 'path/to/bar', namespace_id: namespace.id) } let(:project) { table(:projects).create!(name: 'bar', path: 'path/to/bar', namespace_id: namespace.id) }
subject(:background_migration) { described_class.new } subject(:background_migration) { described_class.new }
......
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