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
8ad12708
Commit
8ad12708
authored
Feb 11, 2019
by
Jarka Košanová
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show only MRs visible to user on milestone detail
parent
66b20a66
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
4 deletions
+61
-4
app/controllers/concerns/milestone_actions.rb
app/controllers/concerns/milestone_actions.rb
+1
-1
app/models/concerns/milestoneish.rb
app/models/concerns/milestoneish.rb
+9
-2
changelogs/unreleased/security-2797-milestone-mrs.yml
changelogs/unreleased/security-2797-milestone-mrs.yml
+5
-0
spec/models/concerns/milestoneish_spec.rb
spec/models/concerns/milestoneish_spec.rb
+46
-1
No files found.
app/controllers/concerns/milestone_actions.rb
View file @
8ad12708
...
@@ -8,7 +8,7 @@ module MilestoneActions
...
@@ -8,7 +8,7 @@ module MilestoneActions
format
.
html
{
redirect_to
milestone_redirect_path
}
format
.
html
{
redirect_to
milestone_redirect_path
}
format
.
json
do
format
.
json
do
render
json:
tabs_json
(
"shared/milestones/_merge_requests_tab"
,
{
render
json:
tabs_json
(
"shared/milestones/_merge_requests_tab"
,
{
merge_requests:
@milestone
.
sorted_merge_requests
,
# rubocop:disable Gitlab/ModuleWithInstanceVariables
merge_requests:
@milestone
.
sorted_merge_requests
(
current_user
)
,
# rubocop:disable Gitlab/ModuleWithInstanceVariables
show_project_name:
true
show_project_name:
true
})
})
end
end
...
...
app/models/concerns/milestoneish.rb
View file @
8ad12708
...
@@ -46,12 +46,19 @@ module Milestoneish
...
@@ -46,12 +46,19 @@ module Milestoneish
end
end
end
end
def
merge_requests_visible_to_user
(
user
)
memoize_per_user
(
user
,
:merge_requests_visible_to_user
)
do
MergeRequestsFinder
.
new
(
user
,
{})
.
execute
.
where
(
milestone_id:
milestoneish_id
)
end
end
def
sorted_issues
(
user
)
def
sorted_issues
(
user
)
issues_visible_to_user
(
user
).
preload_associations
.
sort_by_attribute
(
'label_priority'
)
issues_visible_to_user
(
user
).
preload_associations
.
sort_by_attribute
(
'label_priority'
)
end
end
def
sorted_merge_requests
def
sorted_merge_requests
(
user
)
merge_requests
.
sort_by_attribute
(
'label_priority'
)
merge_requests
_visible_to_user
(
user
)
.
sort_by_attribute
(
'label_priority'
)
end
end
def
upcoming?
def
upcoming?
...
...
changelogs/unreleased/security-2797-milestone-mrs.yml
0 → 100644
View file @
8ad12708
---
title
:
Show only merge requests visible to user on milestone detail page
merge_request
:
author
:
type
:
security
spec/models/concerns/milestoneish_spec.rb
View file @
8ad12708
...
@@ -48,7 +48,7 @@ describe Milestone, 'Milestoneish' do
...
@@ -48,7 +48,7 @@ describe Milestone, 'Milestoneish' do
merge_request_2
=
create
(
:labeled_merge_request
,
labels:
[
label_1
],
source_project:
project
,
source_branch:
'branch_2'
,
milestone:
milestone
)
merge_request_2
=
create
(
:labeled_merge_request
,
labels:
[
label_1
],
source_project:
project
,
source_branch:
'branch_2'
,
milestone:
milestone
)
merge_request_3
=
create
(
:labeled_merge_request
,
labels:
[
label_3
],
source_project:
project
,
source_branch:
'branch_3'
,
milestone:
milestone
)
merge_request_3
=
create
(
:labeled_merge_request
,
labels:
[
label_3
],
source_project:
project
,
source_branch:
'branch_3'
,
milestone:
milestone
)
merge_requests
=
milestone
.
sorted_merge_requests
merge_requests
=
milestone
.
sorted_merge_requests
(
member
)
expect
(
merge_requests
.
first
).
to
eq
(
merge_request_2
)
expect
(
merge_requests
.
first
).
to
eq
(
merge_request_2
)
expect
(
merge_requests
.
second
).
to
eq
(
merge_request_1
)
expect
(
merge_requests
.
second
).
to
eq
(
merge_request_1
)
...
@@ -56,6 +56,51 @@ describe Milestone, 'Milestoneish' do
...
@@ -56,6 +56,51 @@ describe Milestone, 'Milestoneish' do
end
end
end
end
describe
'#merge_requests_visible_to_user'
do
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
milestone:
milestone
)
}
context
'when project is private'
do
before
do
project
.
update
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
end
it
'does not return any merge request for a non member'
do
merge_requests
=
milestone
.
merge_requests_visible_to_user
(
non_member
)
expect
(
merge_requests
).
to
be_empty
end
it
'returns milestone merge requests for a member'
do
merge_requests
=
milestone
.
merge_requests_visible_to_user
(
member
)
expect
(
merge_requests
).
to
contain_exactly
(
merge_request
)
end
end
context
'when project is public'
do
context
'when merge requests are available to anyone'
do
it
'returns milestone merge requests for a non member'
do
merge_requests
=
milestone
.
merge_requests_visible_to_user
(
non_member
)
expect
(
merge_requests
).
to
contain_exactly
(
merge_request
)
end
end
context
'when merge requests are available to project members'
do
before
do
project
.
project_feature
.
update
(
merge_requests_access_level:
ProjectFeature
::
PRIVATE
)
end
it
'does not return any merge request for a non member'
do
merge_requests
=
milestone
.
merge_requests_visible_to_user
(
non_member
)
expect
(
merge_requests
).
to
be_empty
end
it
'returns milestone merge requests for a member'
do
merge_requests
=
milestone
.
merge_requests_visible_to_user
(
member
)
expect
(
merge_requests
).
to
contain_exactly
(
merge_request
)
end
end
end
end
describe
'#closed_items_count'
do
describe
'#closed_items_count'
do
it
'does not count confidential issues for non project members'
do
it
'does not count confidential issues for non project members'
do
expect
(
milestone
.
closed_items_count
(
non_member
)).
to
eq
2
expect
(
milestone
.
closed_items_count
(
non_member
)).
to
eq
2
...
...
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