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
3640bd78
Commit
3640bd78
authored
Feb 03, 2021
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix snippet repository storage move API when snippet does not exist
parent
dc288940
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
6 deletions
+50
-6
changelogs/unreleased/fj-fix-api-when-snippet-does-not-exist.yml
...ogs/unreleased/fj-fix-api-when-snippet-does-not-exist.yml
+5
-0
lib/api/snippet_repository_storage_moves.rb
lib/api/snippet_repository_storage_moves.rb
+6
-1
spec/support/shared_examples/requests/api/repository_storage_moves_shared_examples.rb
.../requests/api/repository_storage_moves_shared_examples.rb
+39
-5
No files found.
changelogs/unreleased/fj-fix-api-when-snippet-does-not-exist.yml
0 → 100644
View file @
3640bd78
---
title
:
Fix snippet repository storage move API when snippet does not exist
merge_request
:
53211
author
:
type
:
fixed
lib/api/snippet_repository_storage_moves.rb
View file @
3640bd78
...
@@ -58,9 +58,14 @@ module API
...
@@ -58,9 +58,14 @@ module API
resource
:snippets
do
resource
:snippets
do
helpers
do
helpers
do
def
user_snippet
def
user_snippet
Snippet
.
find_by
(
id:
params
[
:id
])
# rubocop: disable CodeReuse/ActiveRecord
@user_snippet
||=
Snippet
.
find_by
(
id:
params
[
:id
])
# rubocop: disable CodeReuse/ActiveRecord
end
end
end
end
before
do
not_found!
(
'Snippet'
)
unless
user_snippet
end
desc
'Get a list of all snippets repository storage moves'
do
desc
'Get a list of all snippets repository storage moves'
do
detail
'This feature was introduced in GitLab 13.8.'
detail
'This feature was introduced in GitLab 13.8.'
success
Entities
::
SnippetRepositoryStorageMove
success
Entities
::
SnippetRepositoryStorageMove
...
...
spec/support/shared_examples/requests/api/repository_storage_moves_shared_examples.rb
View file @
3640bd78
...
@@ -85,14 +85,37 @@ RSpec.shared_examples 'repository_storage_moves API' do |container_type|
...
@@ -85,14 +85,37 @@ RSpec.shared_examples 'repository_storage_moves API' do |container_type|
end
end
describe
"GET /
#{
container_type
}
/:id/repository_storage_moves"
do
describe
"GET /
#{
container_type
}
/:id/repository_storage_moves"
do
it_behaves_like
'get container repository storage move list'
do
let
(
:container_id
)
{
container
.
id
}
let
(
:url
)
{
"/
#{
container_type
}
/
#{
container
.
id
}
/repository_storage_moves"
}
let
(
:url
)
{
"/
#{
container_type
}
/
#{
container_id
}
/repository_storage_moves"
}
it_behaves_like
'get container repository storage move list'
context
'non-existent container'
do
let
(
:container_id
)
{
non_existing_record_id
}
it
'returns not found'
do
get
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
describe
"GET /
#{
container_type
}
/:id/repository_storage_moves/:repository_storage_move_id"
do
describe
"GET /
#{
container_type
}
/:id/repository_storage_moves/:repository_storage_move_id"
do
it_behaves_like
'get single container repository storage move'
do
let
(
:container_id
)
{
container
.
id
}
let
(
:url
)
{
"/
#{
container_type
}
/
#{
container
.
id
}
/repository_storage_moves/
#{
repository_storage_move_id
}
"
}
let
(
:url
)
{
"/
#{
container_type
}
/
#{
container_id
}
/repository_storage_moves/
#{
repository_storage_move_id
}
"
}
it_behaves_like
'get single container repository storage move'
context
'non-existent container'
do
let
(
:container_id
)
{
non_existing_record_id
}
let
(
:repository_storage_move_id
)
{
storage_move
.
id
}
it
'returns not found'
do
get
api
(
url
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
end
...
@@ -109,7 +132,8 @@ RSpec.shared_examples 'repository_storage_moves API' do |container_type|
...
@@ -109,7 +132,8 @@ RSpec.shared_examples 'repository_storage_moves API' do |container_type|
end
end
describe
"POST /
#{
container_type
}
/:id/repository_storage_moves"
do
describe
"POST /
#{
container_type
}
/:id/repository_storage_moves"
do
let
(
:url
)
{
"/
#{
container_type
}
/
#{
container
.
id
}
/repository_storage_moves"
}
let
(
:container_id
)
{
container
.
id
}
let
(
:url
)
{
"/
#{
container_type
}
/
#{
container_id
}
/repository_storage_moves"
}
let
(
:destination_storage_name
)
{
'test_second_storage'
}
let
(
:destination_storage_name
)
{
'test_second_storage'
}
def
create_container_repository_storage_move
def
create_container_repository_storage_move
...
@@ -154,6 +178,16 @@ RSpec.shared_examples 'repository_storage_moves API' do |container_type|
...
@@ -154,6 +178,16 @@ RSpec.shared_examples 'repository_storage_moves API' do |container_type|
expect
(
json_response
[
'destination_storage_name'
]).
to
be_present
expect
(
json_response
[
'destination_storage_name'
]).
to
be_present
end
end
end
end
context
'when container does not exist'
do
let
(
:container_id
)
{
non_existing_record_id
}
it
'returns not found'
do
create_container_repository_storage_move
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
describe
"POST /
#{
container_type
.
singularize
}
_repository_storage_moves"
do
describe
"POST /
#{
container_type
.
singularize
}
_repository_storage_moves"
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