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
ecea68ee
Commit
ecea68ee
authored
May 14, 2020
by
Patrick Derichs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add #parent method to milestone
parent
1e638da0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
9 deletions
+27
-9
app/models/milestone.rb
app/models/milestone.rb
+8
-0
ee/app/services/burnup_chart_service.rb
ee/app/services/burnup_chart_service.rb
+1
-9
spec/models/milestone_spec.rb
spec/models/milestone_spec.rb
+18
-0
No files found.
app/models/milestone.rb
View file @
ecea68ee
...
...
@@ -170,6 +170,14 @@ class Milestone < ApplicationRecord
alias_method
:group_milestone?
,
:group_timebox?
alias_method
:project_milestone?
,
:project_timebox?
def
parent
if
group_milestone?
group
else
project
end
end
private
def
milestone_format_reference
(
format
=
:iid
)
...
...
ee/app/services/burnup_chart_service.rb
View file @
ecea68ee
...
...
@@ -41,15 +41,7 @@ class BurnupChartService
attr_reader
:milestone
,
:start_date
,
:due_date
,
:end_date
,
:user
def
can_read_milestone?
Ability
.
allowed?
(
user
,
:read_milestone
,
milestone_parent
)
end
def
milestone_parent
if
milestone
.
group_milestone?
milestone
.
group
else
milestone
.
project
end
Ability
.
allowed?
(
user
,
:read_milestone
,
milestone
.
parent
)
end
def
handle_added_milestone
(
event
,
assigned_milestones
)
...
...
spec/models/milestone_spec.rb
View file @
ecea68ee
...
...
@@ -480,4 +480,22 @@ describe Milestone do
it
{
is_expected
.
not_to
match
(
"
#{
Gitlab
.
config
.
gitlab
.
url
}
/gitlab-org/gitlab-foss/issues/123"
)
}
it
{
is_expected
.
not_to
match
(
"gitlab-org/gitlab-ce/milestones/123"
)
}
end
describe
'#parent'
do
context
'with group'
do
it
'returns the expected parent'
do
group
=
create
(
:group
)
expect
(
build
(
:milestone
,
group:
group
).
parent
).
to
eq
(
group
)
end
end
context
'with project'
do
it
'returns the expected parent'
do
project
=
create
(
:project
)
expect
(
build
(
:milestone
,
project:
project
).
parent
).
to
eq
(
project
)
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