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
f62bce08
Commit
f62bce08
authored
Oct 13, 2020
by
charlie ablett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor tests to use nodes
parent
6285814e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
21 deletions
+15
-21
spec/graphql/types/snippet_type_spec.rb
spec/graphql/types/snippet_type_spec.rb
+15
-21
No files found.
spec/graphql/types/snippet_type_spec.rb
View file @
f62bce08
...
...
@@ -124,7 +124,7 @@ RSpec.describe GitlabSchema.types['Snippet'] do
end
describe
'#blob'
do
let
(
:query_blob
)
{
subject
.
dig
(
'data'
,
'snippets'
,
'
edges'
)[
0
][
'node'
][
'blob'
]
}
let
(
:query_blob
)
{
subject
.
dig
(
'data'
,
'snippets'
,
'
nodes'
)[
0
][
'blob'
]
}
subject
{
GitlabSchema
.
execute
(
snippet_query_for
(
field:
'blob'
),
context:
{
current_user:
user
}).
as_json
}
...
...
@@ -151,21 +151,17 @@ RSpec.describe GitlabSchema.types['Snippet'] do
describe
'#blobs'
do
let_it_be
(
:snippet
)
{
create
(
:personal_snippet
,
:public
,
author:
user
)
}
let
(
:query_blobs
)
{
subject
.
dig
(
'data'
,
'snippets'
,
'
edges'
)[
0
].
dig
(
'node'
,
'blobs'
,
'edg
es'
)
}
let
(
:query_blobs
)
{
subject
.
dig
(
'data'
,
'snippets'
,
'
nodes'
)[
0
].
dig
(
'blobs'
,
'nod
es'
)
}
let
(
:paths
)
{
[]
}
let
(
:query
)
do
%(
{
snippets {
edges {
node {
blobs(paths: #{paths}) {
edges {
node {
name
path
}
}
nodes {
blobs(paths: #{paths}) {
nodes {
name
path
}
}
}
...
...
@@ -188,8 +184,8 @@ RSpec.describe GitlabSchema.types['Snippet'] do
it_behaves_like
'an array'
it
'contains the first blob from the snippet'
do
expect
(
query_blobs
.
first
[
'n
ode'
][
'n
ame'
]).
to
eq
blob
.
name
expect
(
query_blobs
.
first
[
'
node'
][
'
path'
]).
to
eq
blob
.
path
expect
(
query_blobs
.
first
[
'name'
]).
to
eq
blob
.
name
expect
(
query_blobs
.
first
[
'path'
]).
to
eq
blob
.
path
end
end
...
...
@@ -200,7 +196,7 @@ RSpec.describe GitlabSchema.types['Snippet'] do
it_behaves_like
'an array'
it
'contains all the blobs from the repository'
do
resulting_blobs_names
=
query_blobs
.
map
{
|
b
|
b
[
'n
ode'
][
'n
ame'
]
}
resulting_blobs_names
=
query_blobs
.
map
{
|
b
|
b
[
'name'
]
}
expect
(
resulting_blobs_names
).
to
match_array
(
blobs
.
map
(
&
:name
))
end
...
...
@@ -211,7 +207,7 @@ RSpec.describe GitlabSchema.types['Snippet'] do
it_behaves_like
'an array'
it
'returns specific files'
do
resulting_blobs_names
=
query_blobs
.
map
{
|
b
|
b
[
'n
ode'
][
'n
ame'
]
}
resulting_blobs_names
=
query_blobs
.
map
{
|
b
|
b
[
'name'
]
}
expect
(
resulting_blobs_names
).
to
match
(
paths
)
end
...
...
@@ -223,12 +219,10 @@ RSpec.describe GitlabSchema.types['Snippet'] do
%(
{
snippets {
edges {
node {
#{field} {
name
path
}
nodes {
#{field} {
name
path
}
}
}
...
...
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