Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7a623774
Commit
7a623774
authored
Mar 01, 2021
by
Patrick Bajao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor spec to reduce SQL queries
parent
a7c2dc77
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
13 deletions
+43
-13
spec/services/merge_requests/update_service_spec.rb
spec/services/merge_requests/update_service_spec.rb
+43
-13
No files found.
spec/services/merge_requests/update_service_spec.rb
View file @
7a623774
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment