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
67bd277a
Commit
67bd277a
authored
Mar 09, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure the for a merge request only gets executed once.
parent
56811049
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
app/services/issues/resolve_discussions.rb
app/services/issues/resolve_discussions.rb
+3
-1
spec/services/issues/resolve_discussions_spec.rb
spec/services/issues/resolve_discussions_spec.rb
+19
-0
No files found.
app/services/issues/resolve_discussions.rb
View file @
67bd277a
...
@@ -8,7 +8,9 @@ module Issues
...
@@ -8,7 +8,9 @@ module Issues
end
end
def
merge_request_for_resolving_discussions
def
merge_request_for_resolving_discussions
@merge_request_for_resolving_discussions
||=
MergeRequestsFinder
.
new
(
current_user
,
project_id:
project
.
id
).
return
@merge_request_for_resolving_discussions
if
defined?
(
@merge_request_for_resolving_discussions
)
@merge_request_for_resolving_discussions
=
MergeRequestsFinder
.
new
(
current_user
,
project_id:
project
.
id
).
execute
.
execute
.
find_by
(
iid:
merge_request_for_resolving_discussions_iid
)
find_by
(
iid:
merge_request_for_resolving_discussions_iid
)
end
end
...
...
spec/services/issues/resolve_discussions_spec.rb
View file @
67bd277a
...
@@ -22,6 +22,25 @@ describe DummyService, services: true do
...
@@ -22,6 +22,25 @@ describe DummyService, services: true do
let
(
:merge_request
)
{
discussion
.
noteable
}
let
(
:merge_request
)
{
discussion
.
noteable
}
let
(
:other_merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
source_branch:
"other"
)
}
let
(
:other_merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
source_branch:
"other"
)
}
describe
"#merge_request_for_resolving_discussion"
do
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
merge_request_for_resolving_discussions:
merge_request
.
iid
)
}
it
"finds the merge request"
do
expect
(
service
.
merge_request_for_resolving_discussions
).
to
eq
(
merge_request
)
end
it
"only queries for the merge request once"
do
fake_finder
=
double
fake_results
=
double
expect
(
fake_finder
).
to
receive
(
:execute
).
and_return
(
fake_results
).
exactly
(
1
)
expect
(
fake_results
).
to
receive
(
:find_by
).
exactly
(
1
)
expect
(
MergeRequestsFinder
).
to
receive
(
:new
).
and_return
(
fake_finder
).
exactly
(
1
)
2
.
times
{
service
.
merge_request_for_resolving_discussions
}
end
end
describe
"#discussions_to_resolve"
do
describe
"#discussions_to_resolve"
do
it
"contains a single discussion when matching merge request and discussion are passed"
do
it
"contains a single discussion when matching merge request and discussion are passed"
do
service
=
described_class
.
new
(
service
=
described_class
.
new
(
...
...
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