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
Tatuya Kamada
gitlab-ce
Commits
cc24682b
Commit
cc24682b
authored
Jan 27, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unify projects search by removing /projects/:search endpoint
parent
916fae3a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
62 deletions
+4
-62
changelogs/unreleased/22007-unify-projects-search.yml
changelogs/unreleased/22007-unify-projects-search.yml
+4
-0
lib/api/projects.rb
lib/api/projects.rb
+0
-16
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+0
-46
No files found.
changelogs/unreleased/22007-unify-projects-search.yml
0 → 100644
View file @
cc24682b
---
title
:
Unify projects search by removing /projects/:search endpoint
merge_request
:
8877
author
:
lib/api/projects.rb
View file @
cc24682b
...
...
@@ -151,22 +151,6 @@ module API
present_projects
Project
.
all
,
with:
Entities
::
ProjectWithAccess
,
statistics:
params
[
:statistics
]
end
desc
'Search for projects the current user has access to'
do
success
Entities
::
Project
end
params
do
requires
:query
,
type:
String
,
desc:
'The project name to be searched'
use
:sort_params
use
:pagination
end
get
"/search/:query"
,
requirements:
{
query:
/[^\/]+/
}
do
search_service
=
Search
::
GlobalService
.
new
(
current_user
,
search:
params
[
:query
]).
execute
projects
=
search_service
.
objects
(
'projects'
,
params
[
:page
])
projects
=
projects
.
reorder
(
params
[
:order_by
]
=>
params
[
:sort
])
present
paginate
(
projects
),
with:
Entities
::
Project
end
desc
'Create new project'
do
success
Entities
::
Project
end
...
...
spec/requests/api/projects_spec.rb
View file @
cc24682b
...
...
@@ -1085,52 +1085,6 @@ describe API::Projects, api: true do
end
end
describe
'GET /projects/search/:query'
do
let!
(
:query
)
{
'query'
}
let!
(
:search
)
{
create
(
:empty_project
,
name:
query
,
creator_id:
user
.
id
,
namespace:
user
.
namespace
)
}
let!
(
:pre
)
{
create
(
:empty_project
,
name:
"pre_
#{
query
}
"
,
creator_id:
user
.
id
,
namespace:
user
.
namespace
)
}
let!
(
:post
)
{
create
(
:empty_project
,
name:
"
#{
query
}
_post"
,
creator_id:
user
.
id
,
namespace:
user
.
namespace
)
}
let!
(
:pre_post
)
{
create
(
:empty_project
,
name:
"pre_
#{
query
}
_post"
,
creator_id:
user
.
id
,
namespace:
user
.
namespace
)
}
let!
(
:unfound
)
{
create
(
:empty_project
,
name:
'unfound'
,
creator_id:
user
.
id
,
namespace:
user
.
namespace
)
}
let!
(
:internal
)
{
create
(
:empty_project
,
:internal
,
name:
"internal
#{
query
}
"
)
}
let!
(
:unfound_internal
)
{
create
(
:empty_project
,
:internal
,
name:
'unfound internal'
)
}
let!
(
:public
)
{
create
(
:empty_project
,
:public
,
name:
"public
#{
query
}
"
)
}
let!
(
:unfound_public
)
{
create
(
:empty_project
,
:public
,
name:
'unfound public'
)
}
let!
(
:one_dot_two
)
{
create
(
:empty_project
,
:public
,
name:
"one.dot.two"
)
}
shared_examples_for
'project search response'
do
|
args
=
{}
|
it
'returns project search responses'
do
get
api
(
"/projects/search/
#{
args
[
:query
]
}
"
,
current_user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
args
[
:results
])
json_response
.
each
{
|
project
|
expect
(
project
[
'name'
]).
to
match
(
args
[
:match_regex
]
||
/.*
#{
args
[
:query
]
}
.*/
)
}
end
end
context
'when unauthenticated'
do
it_behaves_like
'project search response'
,
query:
'query'
,
results:
1
do
let
(
:current_user
)
{
nil
}
end
end
context
'when authenticated'
do
it_behaves_like
'project search response'
,
query:
'query'
,
results:
6
do
let
(
:current_user
)
{
user
}
end
it_behaves_like
'project search response'
,
query:
'one.dot.two'
,
results:
1
do
let
(
:current_user
)
{
user
}
end
end
context
'when authenticated as a different user'
do
it_behaves_like
'project search response'
,
query:
'query'
,
results:
2
,
match_regex:
/(internal|public) query/
do
let
(
:current_user
)
{
user2
}
end
end
end
describe
'PUT /projects/:id'
do
before
{
project
}
before
{
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