Commit 7a623774 authored by Patrick Bajao's avatar Patrick Bajao

Refactor spec to reduce SQL queries

parent a7c2dc77
......@@ -48,6 +48,8 @@ RSpec.describe MergeRequests::UpdateService, :mailer do
end
context 'valid params' do
let(:locked) { true }
let(:opts) do
{
title: 'New title',
......@@ -58,7 +60,7 @@ RSpec.describe MergeRequests::UpdateService, :mailer do
label_ids: [label.id],
target_branch: 'target',
force_remove_source_branch: '1',
discussion_locked: true
discussion_locked: locked
}
end
......@@ -118,20 +120,20 @@ RSpec.describe MergeRequests::UpdateService, :mailer do
MergeRequests::UpdateService.new(project, user, opts).execute(draft_merge_request)
end
it 'tracks discussion locking' do
merge_request.update!(discussion_locked: false)
context 'when MR is locked' do
context 'when locked again' do
it 'does not track discussion locking' do
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
.to receive(:track_discussion_locked_action).once.with(user: user)
.not_to receive(:track_discussion_locked_action)
opts[:discussion_locked] = true
MergeRequests::UpdateService.new(project, user, opts).execute(merge_request)
end
end
context 'when unlocked' do
it 'tracks dicussion unlocking' do
merge_request.update!(discussion_locked: true)
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
.to receive(:track_discussion_unlocked_action).once.with(user: user)
......@@ -140,6 +142,34 @@ RSpec.describe MergeRequests::UpdateService, :mailer do
MergeRequests::UpdateService.new(project, user, opts).execute(merge_request)
end
end
end
context 'when MR is unlocked' do
let(:locked) { false }
context 'when unlocked again' do
it 'does not track discussion unlocking' do
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
.not_to receive(:track_discussion_unlocked_action)
opts[:discussion_locked] = false
MergeRequests::UpdateService.new(project, user, opts).execute(merge_request)
end
end
context 'when locked' do
it 'tracks dicussion locking' do
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
.to receive(:track_discussion_locked_action).once.with(user: user)
opts[:discussion_locked] = true
MergeRequests::UpdateService.new(project, user, opts).execute(merge_request)
end
end
end
end
context 'updating milestone' do
RSpec.shared_examples 'updates milestone' 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