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
2191103e
Commit
2191103e
authored
Mar 24, 2020
by
charlieablett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor tests to use nodes
parent
fefbb917
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
25 deletions
+23
-25
ee/spec/requests/api/graphql/group/timelogs_spec.rb
ee/spec/requests/api/graphql/group/timelogs_spec.rb
+23
-25
No files found.
ee/spec/requests/api/graphql/group/timelogs_spec.rb
View file @
2191103e
...
...
@@ -14,24 +14,22 @@ describe 'Timelogs through GroupQuery' do
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
milestone:
milestone
,
epic:
epic
)
}
let!
(
:timelog1
)
{
create
(
:timelog
,
issue:
issue
,
user:
user
,
spent_at:
10
.
days
.
ago
)
}
let!
(
:timelog2
)
{
create
(
:timelog
,
spent_at:
15
.
days
.
ago
)
}
let
(
:timelogs_data
)
{
graphql_data
[
'group'
][
'timelogs'
][
'
edg
es'
]
}
let
(
:timelogs_data
)
{
graphql_data
[
'group'
][
'timelogs'
][
'
nod
es'
]
}
let
(
:query
)
do
timelog_node
=
<<~
NODE
edges {
node {
date
timeSpent
user {
username
timelog_nodes
=
<<~
NODE
nodes {
date
timeSpent
user {
username
}
issue {
title
milestone {
title
}
issue
{
epic
{
title
milestone {
title
}
epic {
title
}
}
}
}
...
...
@@ -41,7 +39,7 @@ describe 'Timelogs through GroupQuery' do
[
'groupTimelogsEnabled'
,
query_graphql_field
(
"timelogs"
,
{
startDate:
"
#{
13
.
days
.
ago
.
to_date
}
"
,
endDate:
"
#{
2
.
days
.
ago
.
to_date
}
"
},
timelog_node
timelog_node
s
)]
)
end
...
...
@@ -61,17 +59,17 @@ describe 'Timelogs through GroupQuery' do
it
'returns timelogs successfully'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
graphql_errors
).
to
be_nil
expect
(
node
_array
.
size
).
to
eq
1
expect
(
timelog
_array
.
size
).
to
eq
1
expect
(
graphql_data
[
'group'
][
'groupTimelogsEnabled'
]).
to
be_truthy
end
it
'contains correct data'
do
username
=
node
_array
.
map
{
|
data
|
data
[
'user'
][
'username'
]
}
date
=
node
_array
.
map
{
|
data
|
data
[
'date'
].
to_date
.
to_s
}
time_spent
=
node
_array
.
map
{
|
data
|
data
[
'timeSpent'
]
}
issue_title
=
node
_array
.
map
{
|
data
|
data
[
'issue'
][
'title'
]
}
milestone_title
=
node
_array
.
map
{
|
data
|
data
[
'issue'
][
'milestone'
][
'title'
]
}
epic_title
=
node
_array
.
map
{
|
data
|
data
[
'issue'
][
'epic'
][
'title'
]
}
username
=
timelog
_array
.
map
{
|
data
|
data
[
'user'
][
'username'
]
}
date
=
timelog
_array
.
map
{
|
data
|
data
[
'date'
].
to_date
.
to_s
}
time_spent
=
timelog
_array
.
map
{
|
data
|
data
[
'timeSpent'
]
}
issue_title
=
timelog
_array
.
map
{
|
data
|
data
[
'issue'
][
'title'
]
}
milestone_title
=
timelog
_array
.
map
{
|
data
|
data
[
'issue'
][
'milestone'
][
'title'
]
}
epic_title
=
timelog
_array
.
map
{
|
data
|
data
[
'issue'
][
'epic'
][
'title'
]
}
expect
(
username
).
to
eq
([
user
.
username
])
expect
(
date
).
to
eq
([
timelog1
.
spent_at
.
to_date
.
to_s
])
...
...
@@ -130,9 +128,9 @@ describe 'Timelogs through GroupQuery' do
end
end
def
node
_array
(
extract_attribute
=
nil
)
def
timelog
_array
(
extract_attribute
=
nil
)
timelogs_data
.
map
do
|
item
|
extract_attribute
?
item
[
'node'
][
extract_attribute
]
:
item
[
'node'
]
extract_attribute
?
item
[
extract_attribute
]
:
item
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