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
6426b507
Commit
6426b507
authored
Jun 01, 2018
by
Jarka Kadlecová
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include all ancestors milestones in json list & autocomplete
parent
50fda506
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
14 deletions
+52
-14
app/controllers/projects/milestones_controller.rb
app/controllers/projects/milestones_controller.rb
+5
-4
app/services/projects/autocomplete_service.rb
app/services/projects/autocomplete_service.rb
+1
-1
changelogs/unreleased/36862-subgroup-milestones.yml
changelogs/unreleased/36862-subgroup-milestones.yml
+5
-0
spec/controllers/projects/milestones_controller_spec.rb
spec/controllers/projects/milestones_controller_spec.rb
+26
-9
spec/services/projects/autocomplete_service_spec.rb
spec/services/projects/autocomplete_service_spec.rb
+15
-0
No files found.
app/controllers/projects/milestones_controller.rb
View file @
6426b507
class
Projects::MilestonesController
<
Projects
::
ApplicationController
class
Projects::MilestonesController
<
Projects
::
ApplicationController
include
Gitlab
::
Utils
::
StrongMemoize
include
MilestoneActions
include
MilestoneActions
before_action
:check_issuables_available!
before_action
:check_issuables_available!
...
@@ -103,7 +104,7 @@ class Projects::MilestonesController < Projects::ApplicationController
...
@@ -103,7 +104,7 @@ class Projects::MilestonesController < Projects::ApplicationController
protected
protected
def
milestones
def
milestones
@milestones
||=
begin
strong_memoize
(
:milestones
)
do
MilestonesFinder
.
new
(
search_params
).
execute
MilestonesFinder
.
new
(
search_params
).
execute
end
end
end
end
...
@@ -121,10 +122,10 @@ class Projects::MilestonesController < Projects::ApplicationController
...
@@ -121,10 +122,10 @@ class Projects::MilestonesController < Projects::ApplicationController
end
end
def
search_params
def
search_params
if
@project
.
group
&&
can?
(
current_user
,
:read_group
,
@project
.
group
)
if
request
.
format
.
json?
&&
@project
.
group
&&
can?
(
current_user
,
:read_group
,
@project
.
group
)
group
=
@project
.
group
group
s
=
@project
.
group
.
self_and_ancestors
end
end
params
.
permit
(
:state
).
merge
(
project_ids:
@project
.
id
,
group_ids:
group
&
.
id
)
params
.
permit
(
:state
).
merge
(
project_ids:
@project
.
id
,
group_ids:
group
s
&
.
select
(
:id
)
)
end
end
end
end
app/services/projects/autocomplete_service.rb
View file @
6426b507
...
@@ -11,7 +11,7 @@ module Projects
...
@@ -11,7 +11,7 @@ module Projects
order:
{
due_date: :asc
,
title: :asc
}
order:
{
due_date: :asc
,
title: :asc
}
}
}
finder_params
[
:group_ids
]
=
[
@project
.
group
.
id
]
if
@project
.
group
finder_params
[
:group_ids
]
=
@project
.
group
.
self_and_ancestors
.
select
(
:id
)
if
@project
.
group
MilestonesFinder
.
new
(
finder_params
).
execute
.
select
([
:iid
,
:title
])
MilestonesFinder
.
new
(
finder_params
).
execute
.
select
([
:iid
,
:title
])
end
end
...
...
changelogs/unreleased/36862-subgroup-milestones.yml
0 → 100644
View file @
6426b507
---
title
:
Include milestones from parent groups when assigning a milestone to an issue or merge request
merge_request
:
author
:
type
:
changed
spec/controllers/projects/milestones_controller_spec.rb
View file @
6426b507
...
@@ -57,8 +57,8 @@ describe Projects::MilestonesController do
...
@@ -57,8 +57,8 @@ describe Projects::MilestonesController do
context
"as json"
do
context
"as json"
do
let!
(
:group
)
{
create
(
:group
,
:public
)
}
let!
(
:group
)
{
create
(
:group
,
:public
)
}
let!
(
:group_milestone
)
{
create
(
:milestone
,
group:
group
)
}
let!
(
:group_milestone
)
{
create
(
:milestone
,
group:
group
)
}
let!
(
:group_member
)
{
create
(
:group_member
,
group:
group
,
user:
user
)
}
context
'with a single group ancestor'
do
before
do
before
do
project
.
update
(
namespace:
group
)
project
.
update
(
namespace:
group
)
get
:index
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
format: :json
get
:index
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
format: :json
...
@@ -68,8 +68,25 @@ describe Projects::MilestonesController do
...
@@ -68,8 +68,25 @@ describe Projects::MilestonesController do
milestones
=
assigns
(
:milestones
)
milestones
=
assigns
(
:milestones
)
expect
(
milestones
.
count
).
to
eq
(
2
)
expect
(
milestones
.
count
).
to
eq
(
2
)
expect
(
milestones
.
where
(
project_id:
nil
).
first
).
to
eq
(
group_milestone
)
expect
(
milestones
).
to
match_array
([
milestone
,
group_milestone
])
expect
(
milestones
.
where
(
group_id:
nil
).
first
).
to
eq
(
milestone
)
end
end
context
'with nested groups'
,
:nested_groups
do
let!
(
:subgroup
)
{
create
(
:group
,
:public
,
parent:
group
)
}
let!
(
:subgroup_milestone
)
{
create
(
:milestone
,
group:
subgroup
)
}
before
do
project
.
update
(
namespace:
subgroup
)
get
:index
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
format: :json
end
it
"queries projects milestones and all ancestors milestones"
do
milestones
=
assigns
(
:milestones
)
expect
(
milestones
.
count
).
to
eq
(
3
)
expect
(
milestones
).
to
match_array
([
milestone
,
group_milestone
,
subgroup_milestone
])
end
end
end
end
end
end
end
...
...
spec/services/projects/autocomplete_service_spec.rb
View file @
6426b507
...
@@ -115,5 +115,20 @@ describe Projects::AutocompleteService do
...
@@ -115,5 +115,20 @@ describe Projects::AutocompleteService do
expect
(
milestone_titles
).
to
eq
([
group_milestone2
.
title
,
group_milestone1
.
title
])
expect
(
milestone_titles
).
to
eq
([
group_milestone2
.
title
,
group_milestone1
.
title
])
end
end
context
'with nested groups'
,
:nested_groups
do
let
(
:subgroup
)
{
create
(
:group
,
:public
,
parent:
group
)
}
let!
(
:subgroup_milestone
)
{
create
(
:milestone
,
group:
subgroup
)
}
before
do
project
.
update
(
namespace:
subgroup
)
end
it
'includes project milestones and all acestors milestones'
do
expect
(
milestone_titles
).
to
match_array
(
[
project_milestone
.
title
,
group_milestone2
.
title
,
group_milestone1
.
title
,
subgroup_milestone
.
title
]
)
end
end
end
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