Commit 73118f58 authored by James Fargher's avatar James Fargher

Merge branch 'issue#220040-fix-rails-savebang-issue-models' into 'master'

Fix Rails/SaveBang Rubocop offenses for issue models

See merge request gitlab-org/gitlab!58052
parents 35c4d909 8adeee0f
......@@ -256,8 +256,6 @@ Rails/SaveBang:
- 'spec/models/grafana_integration_spec.rb'
- 'spec/models/group_spec.rb'
- 'spec/models/identity_spec.rb'
- 'spec/models/issue/metrics_spec.rb'
- 'spec/models/issue_spec.rb'
- 'spec/models/jira_import_state_spec.rb'
- 'spec/models/key_spec.rb'
- 'spec/models/lfs_objects_project_spec.rb'
......
---
title: Fix Rails/SaveBang Rubocop offenses for issue models
merge_request: 58052
author: Huzaifa Iftikhar @huzaifaiftikhar
type: fixed
......@@ -38,7 +38,7 @@ RSpec.describe Issue::Metrics do
context "milestones" do
it "records the first time an issue is associated with a milestone" do
time = Time.current
travel_to(time) { subject.update(milestone: create(:milestone, project: project)) }
travel_to(time) { subject.update!(milestone: create(:milestone, project: project)) }
metrics = subject.metrics
expect(metrics).to be_present
......@@ -47,9 +47,9 @@ RSpec.describe Issue::Metrics do
it "does not record the second time an issue is associated with a milestone" do
time = Time.current
travel_to(time) { subject.update(milestone: create(:milestone, project: project)) }
travel_to(time + 2.hours) { subject.update(milestone: nil) }
travel_to(time + 6.hours) { subject.update(milestone: create(:milestone, project: project)) }
travel_to(time) { subject.update!(milestone: create(:milestone, project: project)) }
travel_to(time + 2.hours) { subject.update!(milestone: nil) }
travel_to(time + 6.hours) { subject.update!(milestone: create(:milestone, project: project)) }
metrics = subject.metrics
expect(metrics).to be_present
......@@ -61,7 +61,7 @@ RSpec.describe Issue::Metrics do
it "records the first time an issue is associated with a list label" do
list_label = create(:list).label
time = Time.current
travel_to(time) { subject.update(label_ids: [list_label.id]) }
travel_to(time) { subject.update!(label_ids: [list_label.id]) }
metrics = subject.metrics
expect(metrics).to be_present
......@@ -71,9 +71,9 @@ RSpec.describe Issue::Metrics do
it "does not record the second time an issue is associated with a list label" do
time = Time.current
first_list_label = create(:list).label
travel_to(time) { subject.update(label_ids: [first_list_label.id]) }
travel_to(time) { subject.update!(label_ids: [first_list_label.id]) }
second_list_label = create(:list).label
travel_to(time + 5.hours) { subject.update(label_ids: [second_list_label.id]) }
travel_to(time + 5.hours) { subject.update!(label_ids: [second_list_label.id]) }
metrics = subject.metrics
expect(metrics).to be_present
......
......@@ -337,7 +337,7 @@ RSpec.describe Issue do
end
it 'returns true for a user that is the author of an issue' do
issue.update(author: user)
issue.update!(author: user)
expect(issue.assignee_or_author?(user)).to be_truthy
end
......@@ -675,7 +675,7 @@ RSpec.describe Issue do
expect(user2.assigned_open_issues_count).to eq(0)
issue.assignees = [user2]
issue.save
issue.save!
expect(user1.assigned_open_issues_count).to eq(0)
expect(user2.assigned_open_issues_count).to eq(1)
......@@ -907,7 +907,7 @@ RSpec.describe Issue do
let(:private_project) { build(:project, :private)}
before do
issue.update(project: private_project) # move issue to private project
issue.update!(project: private_project) # move issue to private project
end
shared_examples 'issue visible if user has guest access' do
......@@ -1044,7 +1044,7 @@ RSpec.describe Issue do
with_them do
it 'checks for spam on issues that can be seen anonymously' do
project = reusable_project
project.update(visibility_level: visibility_level)
project.update!(visibility_level: visibility_level)
issue = create(:issue, project: project, confidential: confidential, description: 'original description')
issue.assign_attributes(new_attributes)
......@@ -1058,7 +1058,7 @@ RSpec.describe Issue do
it 'refreshes the number of open issues of the project' do
project = subject.project
expect { subject.destroy }
expect { subject.destroy! }
.to change { project.open_issues_count }.from(1).to(0)
end
end
......@@ -1273,8 +1273,8 @@ RSpec.describe Issue do
let_it_be(:issue) { create(:issue) }
it 'returns a list of emails' do
participant1 = issue.issue_email_participants.create(email: 'a@gitlab.com')
participant2 = issue.issue_email_participants.create(email: 'b@gitlab.com')
participant1 = issue.issue_email_participants.create!(email: 'a@gitlab.com')
participant2 = issue.issue_email_participants.create!(email: 'b@gitlab.com')
expect(issue.email_participants_emails).to contain_exactly(participant1.email, participant2.email)
end
......
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