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
Boxiang Sun
gitlab-ce
Commits
bdf4da81
Commit
bdf4da81
authored
Jul 22, 2019
by
Gosia Ksionek
Committed by
Mayra Cabrera
Jul 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add review remarks
Add cr remarks Add cr remarks
parent
fecafd82
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
5 deletions
+69
-5
app/controllers/projects/cycle_analytics/events_controller.rb
...controllers/projects/cycle_analytics/events_controller.rb
+5
-5
spec/controllers/projects/cycle_analytics/events_controller_spec.rb
...ollers/projects/cycle_analytics/events_controller_spec.rb
+64
-0
No files found.
app/controllers/projects/cycle_analytics/events_controller.rb
View file @
bdf4da81
...
...
@@ -23,7 +23,7 @@ module Projects
end
def
test
options
(
events_params
)[
:branch
]
=
event
s_params
[
:branch_name
]
options
(
cycle_analytics_params
)[
:branch
]
=
cycle_analytic
s_params
[
:branch_name
]
render_events
(
cycle_analytics
[
:test
].
events
)
end
...
...
@@ -50,13 +50,13 @@ module Projects
end
def
cycle_analytics
@cycle_analytics
||=
::
CycleAnalytics
::
ProjectLevel
.
new
(
project
,
options:
options
(
event
s_params
))
@cycle_analytics
||=
::
CycleAnalytics
::
ProjectLevel
.
new
(
project
,
options:
options
(
cycle_analytic
s_params
))
end
def
event
s_params
return
{}
unless
params
[
:
event
s
].
present?
def
cycle_analytic
s_params
return
{}
unless
params
[
:
cycle_analytic
s
].
present?
params
[
:
event
s
].
permit
(
:start_date
,
:branch_name
)
params
[
:
cycle_analytic
s
].
permit
(
:start_date
,
:branch_name
)
end
end
end
...
...
spec/controllers/projects/cycle_analytics/events_controller_spec.rb
0 → 100644
View file @
bdf4da81
# frozen_string_literal: true
require
'spec_helper'
describe
Projects
::
CycleAnalytics
::
EventsController
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
sign_in
(
user
)
project
.
add_maintainer
(
user
)
end
describe
'cycle analytics not set up flag'
do
context
'with no data'
do
it
'is empty'
do
get_issue
expect
(
response
).
to
be_success
expect
(
JSON
.
parse
(
response
.
body
)[
'events'
]).
to
be_empty
end
end
context
'with data'
do
let
(
:milestone
)
{
create
(
:milestone
,
project:
project
,
created_at:
10
.
days
.
ago
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
created_at:
9
.
days
.
ago
)
}
before
do
issue
.
update
(
milestone:
milestone
)
end
it
'is not empty'
do
get_issue
expect
(
response
).
to
be_success
end
it
'contains event detais'
do
get_issue
events
=
JSON
.
parse
(
response
.
body
)[
'events'
]
expect
(
events
).
not_to
be_empty
expect
(
events
.
first
).
to
include
(
'title'
,
'author'
,
'iid'
,
'total_time'
,
'created_at'
,
'url'
)
expect
(
events
.
first
[
'title'
]).
to
eq
(
issue
.
title
)
end
context
'with data older than start date'
do
it
'is empty'
do
get_issue
(
additional_params:
{
cycle_analytics:
{
start_date:
7
}
})
expect
(
response
).
to
be_success
expect
(
JSON
.
parse
(
response
.
body
)[
'events'
]).
to
be_empty
end
end
end
end
def
get_issue
(
additional_params:
{})
params
=
additional_params
.
merge
(
namespace_id:
project
.
namespace
,
project_id:
project
)
get
(
:issue
,
params:
params
,
format: :json
)
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