Commit 867b1096 authored by Rajendra Kadam's avatar Rajendra Kadam Committed by Rémy Coutable

Fix Rails/SaveBang offenses for spec/models/cycle_analytics*

Fixes Rails/SaveBang cop for spec files
parent e2e3b618
...@@ -1111,9 +1111,6 @@ Rails/SaveBang: ...@@ -1111,9 +1111,6 @@ Rails/SaveBang:
- 'spec/models/concerns/subscribable_spec.rb' - 'spec/models/concerns/subscribable_spec.rb'
- 'spec/models/concerns/token_authenticatable_spec.rb' - 'spec/models/concerns/token_authenticatable_spec.rb'
- 'spec/models/container_repository_spec.rb' - 'spec/models/container_repository_spec.rb'
- 'spec/models/cycle_analytics/issue_spec.rb'
- 'spec/models/cycle_analytics/plan_spec.rb'
- 'spec/models/cycle_analytics/production_spec.rb'
- 'spec/models/deploy_keys_project_spec.rb' - 'spec/models/deploy_keys_project_spec.rb'
- 'spec/models/deploy_token_spec.rb' - 'spec/models/deploy_token_spec.rb'
- 'spec/models/deployment_spec.rb' - 'spec/models/deployment_spec.rb'
......
---
title: Fix Rails/SaveBang offenses for spec/models/cycle_analytics/*
merge_request: 41326
author: Rajendra Kadam
type: fixed
...@@ -15,17 +15,17 @@ RSpec.describe 'CycleAnalytics#issue' do ...@@ -15,17 +15,17 @@ RSpec.describe 'CycleAnalytics#issue' do
generate_cycle_analytics_spec( generate_cycle_analytics_spec(
phase: :issue, phase: :issue,
data_fn: -> (context) { { issue: context.build(:issue, project: context.project) } }, data_fn: -> (context) { { issue: context.build(:issue, project: context.project) } },
start_time_conditions: [["issue created", -> (context, data) { data[:issue].save }]], start_time_conditions: [["issue created", -> (context, data) { data[:issue].save! }]],
end_time_conditions: [["issue associated with a milestone", end_time_conditions: [["issue associated with a milestone",
-> (context, data) do -> (context, data) do
if data[:issue].persisted? if data[:issue].persisted?
data[:issue].update(milestone: context.create(:milestone, project: context.project)) data[:issue].update!(milestone: context.create(:milestone, project: context.project))
end end
end], end],
["list label added to issue", ["list label added to issue",
-> (context, data) do -> (context, data) do
if data[:issue].persisted? if data[:issue].persisted?
data[:issue].update(label_ids: [context.create(:list).label_id]) data[:issue].update!(label_ids: [context.create(:list).label_id])
end end
end]], end]],
post_fn: -> (context, data) do post_fn: -> (context, data) do
...@@ -35,7 +35,7 @@ RSpec.describe 'CycleAnalytics#issue' do ...@@ -35,7 +35,7 @@ RSpec.describe 'CycleAnalytics#issue' do
it "returns nil" do it "returns nil" do
regular_label = create(:label) regular_label = create(:label)
issue = create(:issue, project: project) issue = create(:issue, project: project)
issue.update(label_ids: [regular_label.id]) issue.update!(label_ids: [regular_label.id])
create_merge_request_closing_issue(user, project, issue) create_merge_request_closing_issue(user, project, issue)
merge_merge_requests_closing_issue(user, project, issue) merge_merge_requests_closing_issue(user, project, issue)
......
...@@ -22,11 +22,11 @@ RSpec.describe 'CycleAnalytics#plan' do ...@@ -22,11 +22,11 @@ RSpec.describe 'CycleAnalytics#plan' do
end, end,
start_time_conditions: [["issue associated with a milestone", start_time_conditions: [["issue associated with a milestone",
-> (context, data) do -> (context, data) do
data[:issue].update(milestone: context.create(:milestone, project: context.project)) data[:issue].update!(milestone: context.create(:milestone, project: context.project))
end], end],
["list label added to issue", ["list label added to issue",
-> (context, data) do -> (context, data) do
data[:issue].update(label_ids: [context.create(:list).label_id]) data[:issue].update!(label_ids: [context.create(:list).label_id])
end]], end]],
end_time_conditions: [["issue mentioned in a commit", end_time_conditions: [["issue mentioned in a commit",
-> (context, data) do -> (context, data) do
...@@ -40,7 +40,7 @@ RSpec.describe 'CycleAnalytics#plan' do ...@@ -40,7 +40,7 @@ RSpec.describe 'CycleAnalytics#plan' do
branch_name = generate(:branch) branch_name = generate(:branch)
label = create(:label) label = create(:label)
issue = create(:issue, project: project) issue = create(:issue, project: project)
issue.update(label_ids: [label.id]) issue.update!(label_ids: [label.id])
create_commit_referencing_issue(issue, branch_name: branch_name) create_commit_referencing_issue(issue, branch_name: branch_name)
create_merge_request_closing_issue(user, project, issue, source_branch: branch_name) create_merge_request_closing_issue(user, project, issue, source_branch: branch_name)
......
...@@ -15,7 +15,7 @@ RSpec.describe 'CycleAnalytics#production' do ...@@ -15,7 +15,7 @@ RSpec.describe 'CycleAnalytics#production' do
generate_cycle_analytics_spec( generate_cycle_analytics_spec(
phase: :production, phase: :production,
data_fn: -> (context) { { issue: context.build(:issue, project: context.project) } }, data_fn: -> (context) { { issue: context.build(:issue, project: context.project) } },
start_time_conditions: [["issue is created", -> (context, data) { data[:issue].save }]], start_time_conditions: [["issue is created", -> (context, data) { data[:issue].save! }]],
before_end_fn: lambda do |context, data| before_end_fn: lambda do |context, data|
context.create_merge_request_closing_issue(context.user, context.project, data[:issue]) context.create_merge_request_closing_issue(context.user, context.project, data[:issue])
context.merge_merge_requests_closing_issue(context.user, context.project, data[:issue]) context.merge_merge_requests_closing_issue(context.user, context.project, data[:issue])
......
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