Commit ce5c1cf8 authored by Rémy Coutable's avatar Rémy Coutable

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

Fix Rails/SaveBang offenses for spec/services/issues/*

See merge request gitlab-org/gitlab!41312
parents ecdaf606 951b22d6
......@@ -1232,11 +1232,6 @@ Rails/SaveBang:
- 'spec/services/issuable/bulk_update_service_spec.rb'
- 'spec/services/issuable/clone/attributes_rewriter_spec.rb'
- 'spec/services/issuable/common_system_notes_service_spec.rb'
- 'spec/services/issues/close_service_spec.rb'
- 'spec/services/issues/create_service_spec.rb'
- 'spec/services/issues/export_csv_service_spec.rb'
- 'spec/services/issues/reopen_service_spec.rb'
- 'spec/services/issues/update_service_spec.rb'
- 'spec/services/labels/promote_service_spec.rb'
- 'spec/services/members/destroy_service_spec.rb'
- 'spec/services/merge_requests/build_service_spec.rb'
......
---
title: Fix Rails/SaveBang offenses for spec/services/issues/*
merge_request: 41312
author: Rajendra Kadam
type: fixed
......@@ -288,7 +288,7 @@ RSpec.describe Issues::CloseService do
end
it 'deletes milestone issue counters cache' do
issue.update(milestone: create(:milestone, project: project))
issue.update!(milestone: create(:milestone, project: project))
expect_next_instance_of(Milestones::ClosedIssuesCountService, issue.milestone) do |service|
expect(service).to receive(:delete_cache).and_call_original
......
......@@ -119,7 +119,7 @@ RSpec.describe Issues::CreateService do
end
before do
project.update(group: group)
project.update!(group: group)
end
it 'assigns group labels' do
......@@ -295,7 +295,7 @@ RSpec.describe Issues::CreateService do
context "when issuable feature is private" do
before do
project.project_feature.update(issues_access_level: ProjectFeature::PRIVATE,
project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE,
merge_requests_access_level: ProjectFeature::PRIVATE)
end
......@@ -303,7 +303,7 @@ RSpec.describe Issues::CreateService do
levels.each do |level|
it "removes not authorized assignee when project is #{Gitlab::VisibilityLevel.level_name(level)}" do
project.update(visibility_level: level)
project.update!(visibility_level: level)
opts = { title: 'Title', description: 'Description', assignee_ids: [assignee.id] }
issue = described_class.new(project, user, opts).execute
......
......@@ -38,8 +38,8 @@ RSpec.describe Issues::ExportCsvService do
before do
# Creating a timelog touches the updated_at timestamp of issue,
# so create these first.
issue.timelogs.create(time_spent: 360, user: user)
issue.timelogs.create(time_spent: 200, user: user)
issue.timelogs.create!(time_spent: 360, user: user)
issue.timelogs.create!(time_spent: 200, user: user)
issue.update!(milestone: milestone,
assignees: [user],
description: 'Issue with details',
......
......@@ -44,7 +44,7 @@ RSpec.describe Issues::ReopenService do
end
it 'deletes milestone issue counters cache' do
issue.update(milestone: create(:milestone, project: project))
issue.update!(milestone: create(:milestone, project: project))
expect_next_instance_of(Milestones::ClosedIssuesCountService, issue.milestone) do |service|
expect(service).to receive(:delete_cache).and_call_original
......
......@@ -354,7 +354,7 @@ RSpec.describe Issues::UpdateService, :mailer do
end
it 'does not update assignee_id with unauthorized users' do
project.update(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
project.update!(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
update_issue(confidential: true)
non_member = create(:user)
original_assignees = issue.assignees
......@@ -457,7 +457,7 @@ RSpec.describe Issues::UpdateService, :mailer do
it 'sends notifications for subscribers of changed milestone', :sidekiq_might_not_need_inline do
issue.milestone = create(:milestone, project: project)
issue.save
issue.save!
perform_enqueued_jobs do
update_issue(milestone_id: "")
......@@ -470,7 +470,7 @@ RSpec.describe Issues::UpdateService, :mailer do
it 'clears milestone issue counters cache' do
issue.milestone = create(:milestone, project: project)
issue.save
issue.save!
expect_next_instance_of(Milestones::IssuesCountService, issue.milestone) do |service|
expect(service).to receive(:delete_cache).and_call_original
......@@ -718,7 +718,7 @@ RSpec.describe Issues::UpdateService, :mailer do
let(:params) { { label_ids: [label.id], add_label_ids: [label3.id] } }
before do
issue.update(labels: [label2])
issue.update!(labels: [label2])
end
it 'replaces the labels with the ones in label_ids and adds those in add_label_ids' do
......@@ -730,7 +730,7 @@ RSpec.describe Issues::UpdateService, :mailer do
let(:params) { { label_ids: [label.id, label2.id, label3.id], remove_label_ids: [label.id] } }
before do
issue.update(labels: [label, label3])
issue.update!(labels: [label, label3])
end
it 'replaces the labels with the ones in label_ids and removes those in remove_label_ids' do
......@@ -742,7 +742,7 @@ RSpec.describe Issues::UpdateService, :mailer do
let(:params) { { add_label_ids: [label3.id], remove_label_ids: [label.id] } }
before do
issue.update(labels: [label])
issue.update!(labels: [label])
end
it 'adds the passed labels' do
......@@ -759,7 +759,7 @@ RSpec.describe Issues::UpdateService, :mailer do
context 'for a label assigned to an issue' do
it 'removes the label' do
issue.update(labels: [label])
issue.update!(labels: [label])
expect(result.label_ids).to be_empty
end
......@@ -808,7 +808,7 @@ RSpec.describe Issues::UpdateService, :mailer do
levels.each do |level|
it "does not update with unauthorized assignee when project is #{Gitlab::VisibilityLevel.level_name(level)}" do
assignee = create(:user)
project.update(visibility_level: level)
project.update!(visibility_level: level)
feature_visibility_attr = :"#{issue.model_name.plural}_access_level"
project.project_feature.update_attribute(feature_visibility_attr, ProjectFeature::PRIVATE)
......
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