Commit 38b25e5d authored by James Fargher's avatar James Fargher

Merge branch 'issue_220040_5' into 'master'

Fix Rails/SaveBang offenses for ee/spec/models - I I

See merge request gitlab-org/gitlab!75951
parents 04a30ee5 53709c45
......@@ -19,13 +19,6 @@ Rails/SaveBang:
- ee/spec/models/elasticsearch_indexed_namespace_spec.rb
- ee/spec/models/gitlab_subscription_spec.rb
- ee/spec/models/issue_spec.rb
- ee/spec/models/label_note_spec.rb
- ee/spec/models/lfs_object_spec.rb
- ee/spec/models/license_spec.rb
- ee/spec/models/merge_request_spec.rb
- ee/spec/models/merge_train_spec.rb
- ee/spec/models/project_ci_cd_setting_spec.rb
- ee/spec/models/project_spec.rb
- ee/spec/models/protected_environment_spec.rb
- ee/spec/models/repository_spec.rb
- ee/spec/models/scim_identity_spec.rb
......
......@@ -29,7 +29,7 @@ RSpec.describe LabelNote do
context 'when a label is removed' do
it 'returns note correctly' do
events
label.destroy
label.destroy!
events.first.reload
expect(subject.note).to include('deleted label')
......
......@@ -491,7 +491,7 @@ RSpec.describe License do
context 'when a license is destroyed' do
it 'deletes the future_dated_license value in Gitlab::SafeRequestStore' do
future_dated_license.destroy
future_dated_license.destroy!
expect(Gitlab::SafeRequestStore.read(:future_dated_license)).to be_nil
end
......@@ -1276,7 +1276,7 @@ RSpec.describe License do
end
it 'does nothing' do
license.save
license.save!
expect(ApplicationSetting.current.license_trial_ends_on).to be_nil
end
......@@ -1295,7 +1295,7 @@ RSpec.describe License do
end
it 'updates the trial setting during create' do
license.save
license.save!
expect(described_class.eligible_for_trial?).to be_falsey
expect(ApplicationSetting.current.license_trial_ends_on).to eq(tomorrow)
......@@ -1308,11 +1308,11 @@ RSpec.describe License do
before do
gl_license.restrictions = { trial: true }
gl_license.expires_at = Date.tomorrow
ApplicationSetting.current.update license_trial_ends_on: yesterday
ApplicationSetting.current.update! license_trial_ends_on: yesterday
end
it 'does not update existing trial setting' do
license.save
license.save!
expect(ApplicationSetting.current.license_trial_ends_on).to eq(yesterday)
end
......
......@@ -1114,7 +1114,7 @@ RSpec.describe MergeRequest do
before do
allow(merge_request).to receive(:mergeable_state?).and_return(true)
merge_request.target_project.update(approvals_before_merge: 1)
merge_request.target_project.update!(approvals_before_merge: 1)
project.add_developer(user)
end
......@@ -1123,7 +1123,7 @@ RSpec.describe MergeRequest do
end
it 'return true if approved' do
merge_request.approvals.create(user: user)
merge_request.approvals.create!(user: user)
is_expected.to be_truthy
end
......
......@@ -606,7 +606,7 @@ RSpec.describe MergeTrain do
end
describe '#destroy' do
subject { merge_train.destroy }
subject { merge_train.destroy! }
context 'when merge train has a pipeline' do
let(:merge_train) { create(:merge_train, pipeline: pipeline) }
......
......@@ -115,12 +115,12 @@ RSpec.describe ProjectCiCdSetting do
context 'when merge pipelines option was enabled' do
before do
project.update(merge_pipelines_enabled: true)
project.update!(merge_pipelines_enabled: true)
end
context 'when merge pipelines option is disabled' do
before do
project.update(merge_pipelines_enabled: false)
project.update!(merge_pipelines_enabled: false)
end
it { is_expected.to be true }
......@@ -133,12 +133,12 @@ RSpec.describe ProjectCiCdSetting do
context 'when merge pipelines option was disabled' do
before do
project.update(merge_pipelines_enabled: false)
project.update!(merge_pipelines_enabled: false)
end
context 'when merge pipelines option is disabled' do
before do
project.update(merge_pipelines_enabled: true)
project.update!(merge_pipelines_enabled: true)
end
it { is_expected.to be false }
......
......@@ -487,7 +487,7 @@ RSpec.describe Project do
project2 = create(:project)
expect do
project2.update(mirror: true, import_url: generate(:url), mirror_user: project.creator)
project2.update!(mirror: true, import_url: generate(:url), mirror_user: project.creator)
end.to change { ProjectImportState.where(project: project2).count }.from(0).to(1)
end
end
......@@ -514,7 +514,7 @@ RSpec.describe Project do
freeze_time do
expect do
project.update(mirror: true, mirror_user_id: project.creator.id, import_url: generate(:url))
project.update!(mirror: true, mirror_user_id: project.creator.id, import_url: generate(:url))
end.to change { ProjectImportState.count }.by(1)
expect(project.import_state.next_execution_timestamp).to be_like_time(Time.current)
......@@ -528,7 +528,7 @@ RSpec.describe Project do
freeze_time do
expect do
project.update(mirror: true, mirror_user_id: project.creator.id)
project.update!(mirror: true, mirror_user_id: project.creator.id)
end.not_to change { ProjectImportState.count }
expect(project.import_state.next_execution_timestamp).to be_like_time(Time.current)
......@@ -566,7 +566,7 @@ RSpec.describe Project do
end
it 'returns empty if next_execution_timestamp is in the future' do
import_state.update(next_execution_timestamp: timestamp + 2.minutes)
import_state.update!(next_execution_timestamp: timestamp + 2.minutes)
expect(described_class.mirrors_to_sync(timestamp)).to be_empty
end
......@@ -591,7 +591,7 @@ RSpec.describe Project do
end
it 'returns empty if next_execution_timestamp is in the future' do
project.import_state.update(next_execution_timestamp: timestamp + 2.minutes)
project.import_state.update!(next_execution_timestamp: timestamp + 2.minutes)
expect(described_class.mirrors_to_sync(timestamp)).to be_empty
end
......@@ -726,7 +726,7 @@ RSpec.describe Project do
stub_licensed_features(admin_merge_request_approvers_rules: feature_enabled)
stub_application_setting(application_setting => app_setting)
project.update(setting => project_setting)
project.update!(setting => project_setting)
end
it 'shows proper setting' do
......@@ -937,7 +937,7 @@ RSpec.describe Project do
before do
stub_licensed_features(admin_merge_request_approvers_rules: feature_enabled)
stub_application_setting(application_setting => app_setting)
project.update(setting => project_setting)
project.update!(setting => project_setting)
stub_feature_flags(group_merge_request_approval_settings_feature_flag: false)
end
......@@ -1094,7 +1094,7 @@ RSpec.describe Project do
end
it "returns false" do
project.namespace.update(share_with_group_lock: true)
project.namespace.update!(share_with_group_lock: true)
expect(project.allowed_to_share_with_group?).to be_falsey
end
end
......@@ -1266,7 +1266,7 @@ RSpec.describe Project do
expect(RepositoryRemoveRemoteWorker).not_to receive(:perform_async)
project.update(import_url: "http://test.com")
project.update!(import_url: "http://test.com")
end
end
......@@ -2803,7 +2803,7 @@ RSpec.describe Project do
expect(project).to receive(:create_import_state)
project.update(mirror: true, mirror_user: project.owner, import_url: 'http://foo.com')
project.update!(mirror: true, mirror_user: project.owner, import_url: 'http://foo.com')
end
end
......@@ -2953,7 +2953,7 @@ RSpec.describe Project do
before do
stub_ee_application_setting(custom_project_templates_group_id: group2.id)
group2.update(custom_project_templates_group_id: group2_sub2.id)
group2.update!(custom_project_templates_group_id: group2_sub2.id)
create(:project, group: group1)
create_list(:project, 2, group: group2)
......@@ -2997,7 +2997,7 @@ RSpec.describe Project do
context 'group-level custom project templates' do
before do
group.update(custom_project_templates_group_id: subgroup.id)
group.update!(custom_project_templates_group_id: subgroup.id)
end
it 'returns true' 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