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
d8291378
Commit
d8291378
authored
May 26, 2020
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for GraphqlHelpers.graphql_mutation
parent
bc5228ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
0 deletions
+57
-0
spec/support_specs/helpers/graphql_helpers_spec.rb
spec/support_specs/helpers/graphql_helpers_spec.rb
+57
-0
No files found.
spec/support_specs/helpers/graphql_helpers_spec.rb
0 → 100644
View file @
d8291378
# frozen_string_literal: true
require
'spec_helper'
describe
GraphqlHelpers
do
include
GraphqlHelpers
describe
'.graphql_mutation'
do
shared_examples
'correct mutation definition'
do
it
'returns correct mutation definition'
do
query
=
<<~
MUTATION
mutation($updateAlertStatusInput: UpdateAlertStatusInput!) {
updateAlertStatus(input: $updateAlertStatusInput) {
clientMutationId
}
}
MUTATION
variables
=
%q({"updateAlertStatusInput":{"projectPath":"test/project"}})
is_expected
.
to
eq
(
GraphqlHelpers
::
MutationDefinition
.
new
(
query
,
variables
))
end
end
context
'when fields argument is passed'
do
subject
do
graphql_mutation
(
:update_alert_status
,
{
project_path:
'test/project'
},
'clientMutationId'
)
end
it_behaves_like
'correct mutation definition'
end
context
'when block is passed'
do
subject
do
graphql_mutation
(
:update_alert_status
,
{
project_path:
'test/project'
})
do
'clientMutationId'
end
end
it_behaves_like
'correct mutation definition'
end
context
'when both fields and a block are passed'
do
subject
do
graphql_mutation
(
:mutation_name
,
{
variable_name:
'variable/value'
},
'fieldName'
)
do
'fieldName'
end
end
it
'raises an ArgumentError'
do
expect
{
subject
}.
to
raise_error
(
ArgumentError
,
'Please pass either `fields` parameter or a block to `#graphql_mutation`, but not both.'
)
end
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