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
fcf16c30
Commit
fcf16c30
authored
May 26, 2020
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug in snippet create mutation with non ActiveRecord errors
parent
5052d5ac
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
19 deletions
+28
-19
app/graphql/mutations/snippets/create.rb
app/graphql/mutations/snippets/create.rb
+1
-1
changelogs/unreleased/fj-fix-snippet-create-mutation-non-activerecord-errors.yml
...j-fix-snippet-create-mutation-non-activerecord-errors.yml
+5
-0
spec/requests/api/graphql/mutations/snippets/create_spec.rb
spec/requests/api/graphql/mutations/snippets/create_spec.rb
+22
-18
No files found.
app/graphql/mutations/snippets/create.rb
View file @
fcf16c30
...
@@ -60,7 +60,7 @@ module Mutations
...
@@ -60,7 +60,7 @@ module Mutations
snippet
=
service_response
.
payload
[
:snippet
]
snippet
=
service_response
.
payload
[
:snippet
]
{
{
snippet:
s
nippet
.
valid
?
?
snippet
:
nil
,
snippet:
s
ervice_response
.
success
?
?
snippet
:
nil
,
errors:
errors_on_object
(
snippet
)
errors:
errors_on_object
(
snippet
)
}
}
end
end
...
...
changelogs/unreleased/fj-fix-snippet-create-mutation-non-activerecord-errors.yml
0 → 100644
View file @
fcf16c30
---
title
:
Fix bug in snippet create mutation with non ActiveRecord errors
merge_request
:
33085
author
:
type
:
fixed
spec/requests/api/graphql/mutations/snippets/create_spec.rb
View file @
fcf16c30
...
@@ -109,31 +109,21 @@ describe 'Creating a Snippet' do
...
@@ -109,31 +109,21 @@ describe 'Creating a Snippet' do
context
'when the project path is invalid'
do
context
'when the project path is invalid'
do
let
(
:project_path
)
{
'foobar'
}
let
(
:project_path
)
{
'foobar'
}
it
'returns an an error'
do
it_behaves_like
'a mutation that returns top-level errors'
,
subject
errors:
[
Gitlab
::
Graphql
::
Authorize
::
AuthorizeResource
::
RESOURCE_ACCESS_ERROR
]
errors
=
json_response
[
'errors'
]
expect
(
errors
.
first
[
'message'
]).
to
eq
(
Gitlab
::
Graphql
::
Authorize
::
AuthorizeResource
::
RESOURCE_ACCESS_ERROR
)
end
end
end
context
'when the feature is disabled'
do
context
'when the feature is disabled'
do
it
'returns an an error'
do
before
do
project
.
project_feature
.
update_attribute
(
:snippets_access_level
,
ProjectFeature
::
DISABLED
)
project
.
project_feature
.
update_attribute
(
:snippets_access_level
,
ProjectFeature
::
DISABLED
)
subject
errors
=
json_response
[
'errors'
]
expect
(
errors
.
first
[
'message'
]).
to
eq
(
Gitlab
::
Graphql
::
Authorize
::
AuthorizeResource
::
RESOURCE_ACCESS_ERROR
)
end
end
it_behaves_like
'a mutation that returns top-level errors'
,
errors:
[
Gitlab
::
Graphql
::
Authorize
::
AuthorizeResource
::
RESOURCE_ACCESS_ERROR
]
end
end
end
end
context
'when there are ActiveRecord validation errors'
do
shared_examples
'does not create snippet'
do
let
(
:title
)
{
''
}
it_behaves_like
'a mutation that returns errors in the response'
,
errors:
[
"Title can't be blank"
]
it
'does not create the Snippet'
do
it
'does not create the Snippet'
do
expect
do
expect
do
subject
subject
...
@@ -147,7 +137,21 @@ describe 'Creating a Snippet' do
...
@@ -147,7 +137,21 @@ describe 'Creating a Snippet' do
end
end
end
end
context
'when there uploaded files'
do
context
'when there are ActiveRecord validation errors'
do
let
(
:title
)
{
''
}
it_behaves_like
'a mutation that returns errors in the response'
,
errors:
[
"Title can't be blank"
]
it_behaves_like
'does not create snippet'
end
context
'when there non ActiveRecord errors'
do
let
(
:file_name
)
{
'invalid://file/path'
}
it_behaves_like
'a mutation that returns errors in the response'
,
errors:
[
'Repository Error creating the snippet - Invalid file name'
]
it_behaves_like
'does not create snippet'
end
context
'when there are uploaded files'
do
shared_examples
'expected files argument'
do
|
file_value
,
expected_value
|
shared_examples
'expected files argument'
do
|
file_value
,
expected_value
|
let
(
:uploaded_files
)
{
file_value
}
let
(
:uploaded_files
)
{
file_value
}
...
...
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