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
7be1f084
Commit
7be1f084
authored
Feb 12, 2019
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for BaseResolver and update accordingly
parent
91e9e50a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
9 deletions
+59
-9
spec/graphql/resolvers/base_resolver_spec.rb
spec/graphql/resolvers/base_resolver_spec.rb
+31
-0
spec/graphql/resolvers/merge_requests_resolver_spec.rb
spec/graphql/resolvers/merge_requests_resolver_spec.rb
+23
-9
spec/graphql/types/project_type_spec.rb
spec/graphql/types/project_type_spec.rb
+5
-0
No files found.
spec/graphql/resolvers/base_resolver_spec.rb
0 → 100644
View file @
7be1f084
# frozen_string_literal: true
require
'spec_helper'
describe
Resolvers
::
BaseResolver
do
include
GraphqlHelpers
let
(
:resolver
)
do
Class
.
new
(
described_class
)
do
def
resolve
(
**
args
)
[
args
,
args
]
end
end
end
describe
'.single'
do
it
'returns a subclass from the resolver'
do
expect
(
resolver
.
single
.
superclass
).
to
eq
(
resolver
)
end
it
'returns the same subclass every time'
do
expect
(
resolver
.
single
.
object_id
).
to
eq
(
resolver
.
single
.
object_id
)
end
it
'returns a resolver that gives the first result from the original resolver'
do
result
=
resolve
(
resolver
.
single
,
args:
{
test:
1
})
expect
(
result
).
to
eq
(
test:
1
)
end
end
end
spec/graphql/resolvers/merge_requests_resolver_spec.rb
View file @
7be1f084
...
...
@@ -16,9 +16,17 @@ describe Resolvers::MergeRequestsResolver do
let
(
:other_iid
)
{
other_merge_request
.
iid
}
describe
'#resolve'
do
it
'batch-resolves
merge requests by target project full path and
IID'
do
it
'batch-resolves
by target project full path and individual
IID'
do
result
=
batch
(
max_queries:
2
)
do
resolve_mr
(
project
,
iid_1
)
+
resolve_mr
(
project
,
iid_2
)
resolve_mr
(
project
,
iid:
iid_1
)
+
resolve_mr
(
project
,
iid:
iid_2
)
end
expect
(
result
).
to
contain_exactly
(
merge_request_1
,
merge_request_2
)
end
it
'batch-resolves by target project full path and IIDS'
do
result
=
batch
(
max_queries:
2
)
do
resolve_mr
(
project
,
iids:
[
iid_1
,
iid_2
])
end
expect
(
result
).
to
contain_exactly
(
merge_request_1
,
merge_request_2
)
...
...
@@ -26,22 +34,28 @@ describe Resolvers::MergeRequestsResolver do
it
'can batch-resolve merge requests from different projects'
do
result
=
batch
(
max_queries:
3
)
do
resolve_mr
(
project
,
iid_1
)
+
resolve_mr
(
project
,
iid_2
)
+
resolve_mr
(
other_project
,
other_iid
)
resolve_mr
(
project
,
iid
:
iid
_1
)
+
resolve_mr
(
project
,
iid
:
iid
_2
)
+
resolve_mr
(
other_project
,
iid:
other_iid
)
end
expect
(
result
).
to
contain_exactly
(
merge_request_1
,
merge_request_2
,
other_merge_request
)
end
it
'resolves an unknown iid to nil'
do
result
=
batch
{
resolve_mr
(
project
,
-
1
)
}
it
'resolves an unknown iid to be empty'
do
result
=
batch
{
resolve_mr
(
project
,
iid:
-
1
)
}
expect
(
result
).
to
be_empty
end
it
'resolves empty iids to be empty'
do
result
=
batch
{
resolve_mr
(
project
,
iids:
[])
}
expect
(
result
).
to
be_empty
end
end
def
resolve_mr
(
project
,
iid
)
resolve
(
described_class
,
obj:
project
,
args:
{
iid:
iid
}
)
def
resolve_mr
(
project
,
args
)
resolve
(
described_class
,
obj:
project
,
args:
args
)
end
end
spec/graphql/types/project_type_spec.rb
View file @
7be1f084
...
...
@@ -6,12 +6,17 @@ describe GitlabSchema.types['Project'] do
it
{
expect
(
described_class
.
graphql_name
).
to
eq
(
'Project'
)
}
describe
'nested merge request'
do
it
{
expect
(
described_class
).
to
have_graphql_field
(
:merge_requests
)
}
it
{
expect
(
described_class
).
to
have_graphql_field
(
:merge_request
)
}
it
'authorizes the merge request'
do
expect
(
described_class
.
fields
[
'mergeRequest'
])
.
to
require_graphql_authorizations
(
:read_merge_request
)
end
it
'authorizes the merge requests'
do
skip
end
end
describe
'nested issues'
do
...
...
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