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
98d6d491
Commit
98d6d491
authored
Nov 16, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move global milestone specs
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
c79d801b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
26 deletions
+65
-26
app/services/milestones/collection_service.rb
app/services/milestones/collection_service.rb
+0
-26
spec/models/global_milestone_spec.rb
spec/models/global_milestone_spec.rb
+65
-0
No files found.
app/services/milestones/collection_service.rb
deleted
100644 → 0
View file @
c79d801b
module
Milestones
class
CollectionService
<
Milestones
::
BaseService
def
initialize
(
project_milestones
)
@project_milestones
=
project_milestones
.
group_by
(
&
:title
)
end
def
execute
build
(
@project_milestones
)
end
def
milestone
(
title
)
if
title
group_milestone
=
@project_milestones
[
title
].
group_by
(
&
:title
)
build
(
group_milestone
).
first
else
nil
end
end
private
def
build
(
milestone
)
milestone
.
map
{
|
title
,
milestones
|
GroupMilestone
.
new
(
title
,
milestones
)
}
end
end
end
spec/
services/milestones/group_servic
e_spec.rb
→
spec/
models/global_mileston
e_spec.rb
View file @
98d6d491
require
'spec_helper'
describe
Milestones
::
GroupServic
e
do
describe
GlobalMileston
e
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
)
}
...
...
@@ -14,8 +14,7 @@ describe Milestones::GroupService do
let
(
:milestone2_project2
)
{
create
(
:milestone
,
title:
"VD-123"
,
project:
project2
)
}
let
(
:milestone2_project3
)
{
create
(
:milestone
,
title:
"VD-123"
,
project:
project3
)
}
describe
'execute'
do
context
'with valid projects'
do
describe
:build_collection
do
before
do
milestones
=
[
...
...
@@ -26,45 +25,41 @@ describe Milestones::GroupService do
milestone2_project2
,
milestone2_project3
]
@group_milestones
=
Milestones
::
GroupService
.
new
(
milestones
).
execute
@global_milestones
=
GlobalMilestone
.
build_collection
(
milestones
)
end
it
'should have all project milestones'
do
expect
(
@group
_milestones
.
count
).
to
eq
(
2
)
expect
(
@global
_milestones
.
count
).
to
eq
(
2
)
end
it
'should have all project milestones titles'
do
expect
(
@group_milestones
.
map
{
|
group_milestone
|
group_milestone
.
title
}
).
to
match_array
([
'Milestone v1.2'
,
'VD-123'
])
expect
(
@global_milestones
.
map
(
&
:title
)
).
to
match_array
([
'Milestone v1.2'
,
'VD-123'
])
end
it
'should have all project milestones'
do
expect
(
@group_milestones
.
map
{
|
group_milestone
|
group_milestone
.
milestones
.
count
}.
sum
).
to
eq
(
6
)
end
expect
(
@global_milestones
.
map
{
|
group_milestone
|
group_milestone
.
milestones
.
count
}.
sum
).
to
eq
(
6
)
end
end
describe
'milestone'
do
context
'with valid title'
do
describe
:initialize
do
before
do
milestones
=
[
milestone1_project1
,
milestone1_project2
,
milestone1_project3
,
milestone2_project1
,
milestone2_project2
,
milestone2_project3
]
@group_milestones
=
Milestones
::
GroupService
.
new
(
milestones
).
milestone
(
'Milestone v1.2'
)
@global_milestone
=
GlobalMilestone
.
new
(
milestone1_project1
.
title
,
milestones
)
end
it
'should have exactly one group milestone'
do
expect
(
@group_milestones
.
title
).
to
eq
(
'Milestone v1.2'
)
expect
(
@global_milestone
.
title
).
to
eq
(
'Milestone v1.2'
)
end
it
'should have all project milestones with the same title'
do
expect
(
@group_milestones
.
milestones
.
count
).
to
eq
(
3
)
end
expect
(
@global_milestone
.
milestones
.
count
).
to
eq
(
3
)
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