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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
9abbe3cc
Commit
9abbe3cc
authored
Jan 08, 2017
by
Jeff Stubler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change issue show page to group MRs by projects and namespaces
Closes #26466.
parent
5b73e0eb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
2 deletions
+52
-2
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+1
-2
app/services/issues/fetch_referenced_merge_requests_service.rb
...ervices/issues/fetch_referenced_merge_requests_service.rb
+12
-0
changelogs/unreleased/26466-natural-sort-mrs.yml
changelogs/unreleased/26466-natural-sort-mrs.yml
+4
-0
spec/services/issues/fetch_referenced_merge_requests_service_spec.rb
...es/issues/fetch_referenced_merge_requests_service_spec.rb
+35
-0
No files found.
app/controllers/projects/issues_controller.rb
View file @
9abbe3cc
...
@@ -121,8 +121,7 @@ class Projects::IssuesController < Projects::ApplicationController
...
@@ -121,8 +121,7 @@ class Projects::IssuesController < Projects::ApplicationController
end
end
def
referenced_merge_requests
def
referenced_merge_requests
@merge_requests
=
@issue
.
referenced_merge_requests
(
current_user
)
@merge_requests
,
@closed_by_merge_requests
=
::
Issues
::
FetchReferencedMergeRequestsService
.
new
(
project
,
current_user
).
execute
(
issue
)
@closed_by_merge_requests
=
@issue
.
closed_by_merge_requests
(
current_user
)
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
json
do
format
.
json
do
...
...
app/services/issues/fetch_referenced_merge_requests_service.rb
0 → 100644
View file @
9abbe3cc
module
Issues
class
FetchReferencedMergeRequestsService
<
Issues
::
BaseService
def
execute
(
issue
)
referenced_merge_requests
=
issue
.
referenced_merge_requests
(
current_user
)
referenced_merge_requests
=
Gitlab
::
IssuableSorter
.
sort
(
project
,
referenced_merge_requests
)
{
|
i
|
i
.
iid
.
to_s
}
closed_by_merge_requests
=
issue
.
closed_by_merge_requests
(
current_user
)
closed_by_merge_requests
=
Gitlab
::
IssuableSorter
.
sort
(
project
,
closed_by_merge_requests
)
{
|
i
|
i
.
iid
.
to_s
}
[
referenced_merge_requests
,
closed_by_merge_requests
]
end
end
end
changelogs/unreleased/26466-natural-sort-mrs.yml
0 → 100644
View file @
9abbe3cc
---
title
:
Group MRs on issue page by project and namespace.
merge_request
:
8494
author
:
Jeff Stubler
spec/services/issues/fetch_referenced_merge_requests_service_spec.rb
0 → 100644
View file @
9abbe3cc
require
'spec_helper.rb'
describe
Issues
::
FetchReferencedMergeRequestsService
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:other_project
)
{
create
(
:project
)
}
let
(
:mr
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
,
id:
2
)}
let
(
:other_mr
)
{
create
(
:merge_request
,
source_project:
other_project
,
target_project:
other_project
,
id:
1
)}
let
(
:user
)
{
create
(
:user
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
)
}
context
'with mentioned merge requests'
do
it
'returns a list of sorted merge requests'
do
allow
(
issue
).
to
receive
(
:referenced_merge_requests
).
with
(
user
).
and_return
([
other_mr
,
mr
])
mrs
,
closed_by_mrs
=
service
.
execute
(
issue
)
expect
(
mrs
).
to
match_array
([
mr
,
other_mr
])
expect
(
closed_by_mrs
).
to
match_array
([])
end
end
context
'with closed-by merge requests'
do
it
'returns a list of sorted merge requests'
do
allow
(
issue
).
to
receive
(
:closed_by_merge_requests
).
with
(
user
).
and_return
([
other_mr
,
mr
])
mrs
,
closed_by_mrs
=
service
.
execute
(
issue
)
expect
(
mrs
).
to
match_array
([])
expect
(
closed_by_mrs
).
to
match_array
([
mr
,
other_mr
])
end
end
end
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