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
Léo-Paul Géneau
gitlab-ce
Commits
8e52f56d
Commit
8e52f56d
authored
Sep 12, 2018
by
🙈 jacopo beschi 🙉
Committed by
Robert Speicher
Sep 12, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "500 Internal Server Error: Deleting branch of deleted project"
parent
fb81210b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
3 deletions
+41
-3
app/finders/projects_finder.rb
app/finders/projects_finder.rb
+5
-0
changelogs/unreleased/50678-ignores-project-pending-delete.yml
...elogs/unreleased/50678-ignores-project-pending-delete.yml
+5
-0
lib/api/helpers.rb
lib/api/helpers.rb
+5
-3
spec/finders/projects_finder_spec.rb
spec/finders/projects_finder_spec.rb
+7
-0
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+19
-0
No files found.
app/finders/projects_finder.rb
View file @
8e52f56d
...
...
@@ -49,6 +49,7 @@ class ProjectsFinder < UnionFinder
collection
=
by_search
(
collection
)
collection
=
by_archived
(
collection
)
collection
=
by_custom_attributes
(
collection
)
collection
=
by_deleted_status
(
collection
)
sort
(
collection
)
end
...
...
@@ -131,6 +132,10 @@ class ProjectsFinder < UnionFinder
params
[
:search
].
present?
?
items
.
search
(
params
[
:search
])
:
items
end
def
by_deleted_status
(
items
)
params
[
:without_deleted
].
present?
?
items
.
without_deleted
:
items
end
def
sort
(
items
)
params
[
:sort
].
present?
?
items
.
sort_by_attribute
(
params
[
:sort
])
:
items
.
order_id_desc
end
...
...
changelogs/unreleased/50678-ignores-project-pending-delete.yml
0 → 100644
View file @
8e52f56d
---
title
:
Excludes project marked from deletion to projects API
merge_request
:
21542
author
:
Jacopo Beschi @jacopo-beschi
type
:
changed
lib/api/helpers.rb
View file @
8e52f56d
...
...
@@ -103,10 +103,12 @@ module API
end
def
find_project
(
id
)
projects
=
Project
.
without_deleted
if
id
.
is_a?
(
Integer
)
||
id
=~
/^\d+$/
Project
.
find_by
(
id:
id
)
projects
.
find_by
(
id:
id
)
elsif
id
.
include?
(
"/"
)
Project
.
find_by_full_path
(
id
)
projects
.
find_by_full_path
(
id
)
end
end
...
...
@@ -386,7 +388,7 @@ module API
end
def
project_finder_params
finder_params
=
{}
finder_params
=
{
without_deleted:
true
}
finder_params
[
:owned
]
=
true
if
params
[
:owned
].
present?
finder_params
[
:non_public
]
=
true
if
params
[
:membership
].
present?
finder_params
[
:starred
]
=
true
if
params
[
:starred
].
present?
...
...
spec/finders/projects_finder_spec.rb
View file @
8e52f56d
...
...
@@ -174,6 +174,13 @@ describe ProjectsFinder do
end
end
describe
'filter by without_deleted'
do
let
(
:params
)
{
{
without_deleted:
true
}
}
let!
(
:pending_delete_project
)
{
create
(
:project
,
:public
,
pending_delete:
true
)
}
it
{
is_expected
.
to
match_array
([
public_project
,
internal_project
])
}
end
describe
'sorting'
do
let
(
:params
)
{
{
sort:
'name_asc'
}
}
...
...
spec/requests/api/projects_spec.rb
View file @
8e52f56d
...
...
@@ -148,6 +148,16 @@ describe API::Projects do
expect
(
json_response
.
first
.
keys
).
to
include
(
'open_issues_count'
)
end
it
'does not include projects marked for deletion'
do
project
.
update
(
pending_delete:
true
)
get
api
(
'/projects'
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
map
{
|
p
|
p
[
'id'
]
}).
not_to
include
(
project
.
id
)
end
it
'does not include open_issues_count if issues are disabled'
do
project
.
project_feature
.
update_attribute
(
:issues_access_level
,
ProjectFeature
::
DISABLED
)
...
...
@@ -1012,6 +1022,15 @@ describe API::Projects do
expect
(
json_response
).
not_to
include
(
"import_error"
)
end
it
'returns 404 when project is marked for deletion'
do
project
.
update
(
pending_delete:
true
)
get
api
(
"/projects/
#{
project
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Project Not Found'
)
end
context
'links exposure'
do
it
'exposes related resources full URIs'
do
get
api
(
"/projects/
#{
project
.
id
}
"
,
user
)
...
...
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