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
Jérome Perrin
gitlab-ce
Commits
b5132118
Commit
b5132118
authored
Sep 23, 2016
by
Ahmad Sherif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure milestones passed to GlobalMilestone is an ActiveRecord::Relation
parent
b8bfe50a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
15 deletions
+7
-15
app/models/global_milestone.rb
app/models/global_milestone.rb
+4
-13
spec/models/global_milestone_spec.rb
spec/models/global_milestone_spec.rb
+3
-2
No files found.
app/models/global_milestone.rb
View file @
b5132118
...
...
@@ -8,7 +8,8 @@ class GlobalMilestone
milestones
=
milestones
.
group_by
(
&
:title
)
milestones
.
map
do
|
title
,
milestones
|
new
(
title
,
milestones
)
milestones_relation
=
Milestone
.
where
(
id:
milestones
.
map
(
&
:id
))
new
(
title
,
milestones_relation
)
end
end
...
...
@@ -61,11 +62,11 @@ class GlobalMilestone
end
def
participants
@participants
||=
milestones
_relation
.
includes
(
:participants
).
map
(
&
:participants
).
flatten
.
compact
.
uniq
@participants
||=
milestones
.
includes
(
:participants
).
map
(
&
:participants
).
flatten
.
compact
.
uniq
end
def
labels
@labels
||=
GlobalLabel
.
build_collection
(
milestones
_relation
.
includes
(
:labels
).
map
(
&
:labels
).
flatten
)
@labels
||=
GlobalLabel
.
build_collection
(
milestones
.
includes
(
:labels
).
map
(
&
:labels
).
flatten
)
.
sort_by!
(
&
:title
)
end
...
...
@@ -89,14 +90,4 @@ class GlobalMilestone
end
end
end
private
def
milestones_relation
@milestones_relation
||=
if
milestones
.
is_a?
(
ActiveRecord
::
Relation
)
milestones
else
Milestone
.
where
(
id:
milestones
.
map
(
&
:id
))
end
end
end
spec/models/global_milestone_spec.rb
View file @
b5132118
...
...
@@ -50,8 +50,9 @@ describe GlobalMilestone, models: true do
milestone1_project2
,
milestone1_project3
,
]
milestones_relation
=
Milestone
.
where
(
id:
milestones
.
map
(
&
:id
))
@global_milestone
=
GlobalMilestone
.
new
(
milestone1_project1
.
title
,
milestones
)
@global_milestone
=
GlobalMilestone
.
new
(
milestone1_project1
.
title
,
milestones
_relation
)
end
it
'has exactly one group milestone'
do
...
...
@@ -67,7 +68,7 @@ describe GlobalMilestone, models: true do
let
(
:milestone
)
{
create
(
:milestone
,
title:
"git / test"
,
project:
project1
)
}
it
'strips out slashes and spaces'
do
global_milestone
=
GlobalMilestone
.
new
(
milestone
.
title
,
[
milestone
]
)
global_milestone
=
GlobalMilestone
.
new
(
milestone
.
title
,
Milestone
.
where
(
id:
milestone
.
id
)
)
expect
(
global_milestone
.
safe_title
).
to
eq
(
'git-test'
)
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