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
Tatuya Kamada
gitlab-ce
Commits
71a9bcd3
Commit
71a9bcd3
authored
Sep 07, 2016
by
Timothy Andrew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test the 'review' cycle analytics phase.
parent
f77c952a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
spec/models/cycle_analytics/review_spec.rb
spec/models/cycle_analytics/review_spec.rb
+45
-0
No files found.
spec/models/cycle_analytics/review_spec.rb
0 → 100644
View file @
71a9bcd3
require
'spec_helper'
describe
'CycleAnalytics#review'
,
feature:
true
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:from_date
)
{
10
.
days
.
ago
}
let
(
:user
)
{
create
(
:user
,
:admin
)
}
subject
{
CycleAnalytics
.
new
(
project
,
from:
from_date
)
}
def
create_merge_request_closing_issue
(
issue
)
source_branch
=
FFaker
::
Product
.
brand
project
.
repository
.
add_branch
(
user
,
source_branch
,
'master'
)
sha
=
project
.
repository
.
commit_file
(
user
,
FFaker
::
Product
.
brand
,
"content"
,
"commit message"
,
source_branch
,
false
)
project
.
repository
.
commit
(
sha
)
opts
=
{
title:
'Awesome merge_request'
,
description:
"Fixes
#{
issue
.
to_reference
}
"
,
source_branch:
source_branch
,
target_branch:
'master'
}
MergeRequests
::
CreateService
.
new
(
project
,
user
,
opts
).
execute
end
def
merge_merge_requests_closing_issue
(
issue
)
merge_requests
=
issue
.
closed_by_merge_requests
merge_requests
.
each
{
|
merge_request
|
MergeRequests
::
MergeService
.
new
(
project
,
user
).
execute
(
merge_request
)
}
end
generate_cycle_analytics_spec
(
phase: :review
,
data_fn:
->
(
context
)
{
{
issue:
context
.
create
(
:issue
,
project:
context
.
project
)
}
},
start_time_conditions:
[[
"merge request that closes issue is created"
,
->
(
context
,
data
)
{
context
.
create_merge_request_closing_issue
(
data
[
:issue
])
}]],
end_time_conditions:
[[
"merge request that closes issue is merged"
,
->
(
context
,
data
)
{
context
.
merge_merge_requests_closing_issue
(
data
[
:issue
])
}]])
context
"when a regular merge request (that doesn't close the issue) is created and merged"
do
it
"returns nil"
do
5
.
times
do
MergeRequests
::
MergeService
.
new
(
project
,
user
).
execute
(
create
(
:merge_request
))
end
expect
(
subject
.
review
).
to
be_nil
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