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
71355af6
Commit
71355af6
authored
Aug 07, 2020
by
Luke Duncalfe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GraphQL TimeType to throw GraphQL::CoercionErrors
parent
3f6b3993
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
3 deletions
+15
-3
app/graphql/types/time_type.rb
app/graphql/types/time_type.rb
+2
-0
spec/graphql/types/time_type_spec.rb
spec/graphql/types/time_type_spec.rb
+10
-0
spec/requests/api/graphql/mutations/issues/set_due_date_spec.rb
...equests/api/graphql/mutations/issues/set_due_date_spec.rb
+3
-3
No files found.
app/graphql/types/time_type.rb
View file @
71355af6
...
...
@@ -7,6 +7,8 @@ module Types
def
self
.
coerce_input
(
value
,
ctx
)
Time
.
parse
(
value
)
rescue
ArgumentError
,
TypeError
=>
e
raise
GraphQL
::
CoercionError
,
e
.
message
end
def
self
.
coerce_result
(
value
,
ctx
)
...
...
spec/graphql/types/time_type_spec.rb
View file @
71355af6
...
...
@@ -15,4 +15,14 @@ RSpec.describe GitlabSchema.types['Time'] do
it
'coerces an ISO-time into Time object'
do
expect
(
described_class
.
coerce_isolated_input
(
iso
)).
to
eq
(
time
)
end
it
'rejects invalid input'
do
expect
{
described_class
.
coerce_isolated_input
(
'not valid'
)
}
.
to
raise_error
(
GraphQL
::
CoercionError
)
end
it
'rejects nil'
do
expect
{
described_class
.
coerce_isolated_input
(
nil
)
}
.
to
raise_error
(
GraphQL
::
CoercionError
)
end
end
spec/requests/api/graphql/mutations/issues/set_due_date_spec.rb
View file @
71355af6
...
...
@@ -49,13 +49,13 @@ RSpec.describe 'Setting Due Date of an issue' do
expect
(
mutation_response
[
'issue'
][
'dueDate'
]).
to
eq
(
2
.
days
.
since
.
to_date
.
to_s
)
end
context
'when
passing due date without a date valu
e'
do
context
'when
the due date value is not a valid tim
e'
do
let
(
:input
)
{
{
due_date:
'test'
}
}
it
'returns
internal server
error'
do
it
'returns
a coercion
error'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
graphql_errors
).
to
include
(
a_hash_including
(
'message'
=>
'Internal server error'
))
expect
(
graphql_errors
).
to
include
(
a_hash_including
(
'message'
=>
/provided invalid value for dueDate/
))
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