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
ced433ec
Commit
ced433ec
authored
Oct 28, 2021
by
Alexandru Croitor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exclude project namespace from namespaces API
Exclude project namespace from `exists` namespaces API endpoint
parent
b829ab9f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
lib/api/namespaces.rb
lib/api/namespaces.rb
+1
-1
spec/requests/api/namespaces_spec.rb
spec/requests/api/namespaces_spec.rb
+22
-0
No files found.
lib/api/namespaces.rb
View file @
ced433ec
...
@@ -70,7 +70,7 @@ module API
...
@@ -70,7 +70,7 @@ module API
get
':namespace/exists'
,
requirements:
API
::
NAMESPACE_OR_PROJECT_REQUIREMENTS
do
get
':namespace/exists'
,
requirements:
API
::
NAMESPACE_OR_PROJECT_REQUIREMENTS
do
namespace_path
=
params
[
:namespace
]
namespace_path
=
params
[
:namespace
]
exists
=
Namespace
.
by_parent
(
params
[
:parent_id
]).
filter_by_path
(
namespace_path
).
exists?
exists
=
Namespace
.
without_project_namespaces
.
by_parent
(
params
[
:parent_id
]).
filter_by_path
(
namespace_path
).
exists?
suggestions
=
exists
?
[
Namespace
.
clean_path
(
namespace_path
)]
:
[]
suggestions
=
exists
?
[
Namespace
.
clean_path
(
namespace_path
)]
:
[]
present
:exists
,
exists
present
:exists
,
exists
...
...
spec/requests/api/namespaces_spec.rb
View file @
ced433ec
...
@@ -272,6 +272,16 @@ RSpec.describe API::Namespaces do
...
@@ -272,6 +272,16 @@ RSpec.describe API::Namespaces do
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
context
'when requesting project_namespace'
do
let
(
:namespace_id
)
{
project_namespace
.
id
}
it
'returns authentication error'
do
get
api
(
"/namespaces/
#{
project_namespace
.
path
}
/exists"
),
params:
{
parent_id:
group2
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
end
end
context
'when authenticated'
do
context
'when authenticated'
do
...
@@ -330,6 +340,18 @@ RSpec.describe API::Namespaces do
...
@@ -330,6 +340,18 @@ RSpec.describe API::Namespaces do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
.
body
).
to
eq
(
expected_json
)
expect
(
response
.
body
).
to
eq
(
expected_json
)
end
end
context
'when requesting project_namespace'
do
let
(
:namespace_id
)
{
project_namespace
.
id
}
it
'returns JSON indicating the namespace does not exist without a suggestion'
do
get
api
(
"/namespaces/
#{
project_namespace
.
path
}
/exists"
,
user
),
params:
{
parent_id:
group2
.
id
}
expected_json
=
{
exists:
false
,
suggests:
[]
}.
to_json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
.
body
).
to
eq
(
expected_json
)
end
end
end
end
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