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
db0f9ef4
Commit
db0f9ef4
authored
Jan 16, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make cycle_analytics_events_spec.rb side-effect free
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
79373bdc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
21 deletions
+14
-21
spec/requests/projects/cycle_analytics_events_spec.rb
spec/requests/projects/cycle_analytics_events_spec.rb
+14
-21
No files found.
spec/requests/projects/cycle_analytics_events_spec.rb
View file @
db0f9ef4
require
'spec_helper'
describe
'cycle analytics events'
do
include
ApiHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
public_builds:
false
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
created_at:
2
.
days
.
ago
)
}
...
...
@@ -20,19 +22,19 @@ describe 'cycle analytics events' do
it
'lists the issue events'
do
get
namespace_project_cycle_analytics_issue_path
(
project
.
namespace
,
project
,
format: :json
)
expect
(
json_response
[
'events'
]).
not_to
be_empty
first_issue_iid
=
Issue
.
order
(
created_at: :desc
).
pluck
(
:iid
).
first
.
to_s
first_issue_iid
=
project
.
issues
.
sort
(
:created_desc
).
pluck
(
:iid
).
first
.
to_s
expect
(
json_response
[
'events'
]).
not_to
be_empty
expect
(
json_response
[
'events'
].
first
[
'iid'
]).
to
eq
(
first_issue_iid
)
end
it
'lists the plan events'
do
get
namespace_project_cycle_analytics_plan_path
(
project
.
namespace
,
project
,
format: :json
)
expect
(
json_response
[
'events'
]).
not_to
be_empty
first_mr_short_sha
=
project
.
merge_requests
.
sort
(
:created_asc
).
first
.
commits
.
first
.
short_id
expect
(
json_response
[
'events'
].
first
[
'short_sha'
]).
to
eq
(
MergeRequest
.
last
.
commits
.
first
.
short_id
)
expect
(
json_response
[
'events'
]).
not_to
be_empty
expect
(
json_response
[
'events'
].
first
[
'short_sha'
]).
to
eq
(
first_mr_short_sha
)
end
it
'lists the code events'
do
...
...
@@ -40,7 +42,7 @@ describe 'cycle analytics events' do
expect
(
json_response
[
'events'
]).
not_to
be_empty
first_mr_iid
=
project
.
merge_requests
.
order
(
id: :
desc
).
pluck
(
:iid
).
first
.
to_s
first_mr_iid
=
project
.
merge_requests
.
sort
(
:created_
desc
).
pluck
(
:iid
).
first
.
to_s
expect
(
json_response
[
'events'
].
first
[
'iid'
]).
to
eq
(
first_mr_iid
)
end
...
...
@@ -49,17 +51,15 @@ describe 'cycle analytics events' do
get
namespace_project_cycle_analytics_test_path
(
project
.
namespace
,
project
,
format: :json
)
expect
(
json_response
[
'events'
]).
not_to
be_empty
expect
(
json_response
[
'events'
].
first
[
'date'
]).
not_to
be_empty
end
it
'lists the review events'
do
get
namespace_project_cycle_analytics_review_path
(
project
.
namespace
,
project
,
format: :json
)
expect
(
json_response
[
'events'
]).
not_to
be_empty
first_mr_iid
=
MergeRequest
.
order
(
created_at: :desc
).
pluck
(
:iid
).
first
.
to_s
first_mr_iid
=
project
.
merge_requests
.
sort
(
:created_desc
).
pluck
(
:iid
).
first
.
to_s
expect
(
json_response
[
'events'
]).
not_to
be_empty
expect
(
json_response
[
'events'
].
first
[
'iid'
]).
to
eq
(
first_mr_iid
)
end
...
...
@@ -67,35 +67,32 @@ describe 'cycle analytics events' do
get
namespace_project_cycle_analytics_staging_path
(
project
.
namespace
,
project
,
format: :json
)
expect
(
json_response
[
'events'
]).
not_to
be_empty
expect
(
json_response
[
'events'
].
first
[
'date'
]).
not_to
be_empty
end
it
'lists the production events'
do
get
namespace_project_cycle_analytics_production_path
(
project
.
namespace
,
project
,
format: :json
)
expect
(
json_response
[
'events'
]).
not_to
be_empty
first_issue_iid
=
Issue
.
order
(
created_at: :desc
).
pluck
(
:iid
).
first
.
to_s
first_issue_iid
=
project
.
issues
.
sort
(
:created_desc
).
pluck
(
:iid
).
first
.
to_s
expect
(
json_response
[
'events'
]).
not_to
be_empty
expect
(
json_response
[
'events'
].
first
[
'iid'
]).
to
eq
(
first_issue_iid
)
end
context
'specific branch'
do
it
'lists the test events'
do
branch
=
MergeRequest
.
first
.
source_branch
branch
=
project
.
merge_requests
.
first
.
source_branch
get
namespace_project_cycle_analytics_test_path
(
project
.
namespace
,
project
,
format: :json
,
branch:
branch
)
expect
(
json_response
[
'events'
]).
not_to
be_empty
expect
(
json_response
[
'events'
].
first
[
'date'
]).
not_to
be_empty
end
end
context
'with private project and builds'
do
before
do
ProjectMember
.
first
.
update
(
access_level:
Gitlab
::
Access
::
GUEST
)
project
.
members
.
first
.
update
(
access_level:
Gitlab
::
Access
::
GUEST
)
end
it
'does not list the test events'
do
...
...
@@ -118,10 +115,6 @@ describe 'cycle analytics events' do
end
end
def
json_response
JSON
.
parse
(
response
.
body
)
end
def
create_cycle
milestone
=
create
(
:milestone
,
project:
project
)
issue
.
update
(
milestone:
milestone
)
...
...
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