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
22f44b50
Commit
22f44b50
authored
Aug 15, 2018
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add users search results to project scoped search
parent
70261ff1
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
19 deletions
+82
-19
app/services/search/project_service.rb
app/services/search/project_service.rb
+1
-1
app/views/search/_category.html.haml
app/views/search/_category.html.haml
+6
-0
lib/gitlab/project_search_results.rb
lib/gitlab/project_search_results.rb
+6
-0
spec/features/global_search_spec.rb
spec/features/global_search_spec.rb
+0
-18
spec/features/search/user_searches_for_users_spec.rb
spec/features/search/user_searches_for_users_spec.rb
+53
-0
spec/lib/gitlab/project_search_results_spec.rb
spec/lib/gitlab/project_search_results_spec.rb
+16
-0
No files found.
app/services/search/project_service.rb
View file @
22f44b50
...
...
@@ -16,7 +16,7 @@ module Search
end
def
scope
@scope
||=
%w[notes issues merge_requests milestones wiki_blobs commits]
.
delete
(
params
[
:scope
])
{
'blobs'
}
@scope
||=
%w[notes issues merge_requests milestones wiki_blobs commits
users
]
.
delete
(
params
[
:scope
])
{
'blobs'
}
end
end
end
app/views/search/_category.html.haml
View file @
22f44b50
...
...
@@ -45,6 +45,12 @@
=
_
(
"Commits"
)
%span
.badge.badge-pill
=
@search_results
.
commits_count
-
if
can?
(
current_user
,
:read_users_list
)
%li
{
class:
active_when
(
@scope
==
'users'
)
}
=
link_to
search_filter_path
(
scope:
'users'
)
do
Users
%span
.badge.badge-pill
=
limited_count
(
@search_results
.
limited_users_count
)
-
elsif
@show_snippets
%li
{
class:
active_when
(
@scope
==
'snippet_blobs'
)
}
...
...
lib/gitlab/project_search_results.rb
View file @
22f44b50
...
...
@@ -22,11 +22,17 @@ module Gitlab
paginated_blobs
(
wiki_blobs
,
page
)
when
'commits'
Kaminari
.
paginate_array
(
commits
).
page
(
page
).
per
(
per_page
)
when
'users'
users
.
page
(
page
).
per
(
per_page
)
else
super
(
scope
,
page
,
false
)
end
end
def
users
super
.
where
(
id:
@project
.
users
)
end
def
blobs_count
@blobs_count
||=
blobs
.
count
end
...
...
spec/features/global_search_spec.rb
View file @
22f44b50
...
...
@@ -25,22 +25,4 @@ describe 'Global search' do
expect
(
page
).
to
have_selector
(
'.gl-pagination .next'
)
end
end
describe
'users search'
do
it
'shows the found user under the Users tab'
do
create
(
:user
,
username:
'gob_bluth'
,
name:
'Gob Bluth'
)
visit
dashboard_projects_path
fill_in
'search'
,
with:
'gob'
click_button
'Go'
expect
(
page
).
to
have_content
(
'Users 1'
)
click_on
(
'Users 1'
)
expect
(
page
).
to
have_content
(
'Gob Bluth'
)
expect
(
page
).
to
have_content
(
'@gob_bluth'
)
end
end
end
spec/features/search/user_searches_for_users_spec.rb
0 → 100644
View file @
22f44b50
require
'spec_helper'
describe
'User searches for users'
do
context
'when on the dashboard'
do
it
'finds the user'
do
create
(
:user
,
username:
'gob_bluth'
,
name:
'Gob Bluth'
)
sign_in
(
create
(
:user
))
visit
dashboard_projects_path
fill_in
'search'
,
with:
'gob'
click_button
'Go'
expect
(
page
).
to
have_content
(
'Users 1'
)
click_on
(
'Users 1'
)
expect
(
page
).
to
have_content
(
'Gob Bluth'
)
expect
(
page
).
to
have_content
(
'@gob_bluth'
)
end
end
context
'when on the project page'
do
it
'finds the user belonging to the project'
do
project
=
create
(
:project
)
user1
=
create
(
:user
,
username:
'gob_bluth'
,
name:
'Gob Bluth'
)
create
(
:project_member
,
:developer
,
user:
user1
,
project:
project
)
user2
=
create
(
:user
,
username:
'michael_bluth'
,
name:
'Michael Bluth'
)
create
(
:project_member
,
:developer
,
user:
user2
,
project:
project
)
create
(
:user
,
username:
'gob_2018'
,
name:
'George Oscar Bluth'
)
sign_in
(
user1
)
visit
projects_path
(
project
)
fill_in
'search'
,
with:
'gob'
click_button
'Go'
expect
(
page
).
to
have_content
(
'Gob Bluth'
)
expect
(
page
).
to
have_content
(
'@gob_bluth'
)
expect
(
page
).
not_to
have_content
(
'Michael Bluth'
)
expect
(
page
).
not_to
have_content
(
'@michael_bluth'
)
expect
(
page
).
not_to
have_content
(
'George Oscar Bluth'
)
expect
(
page
).
not_to
have_content
(
'@gob_2018'
)
end
end
end
spec/lib/gitlab/project_search_results_spec.rb
View file @
22f44b50
...
...
@@ -412,4 +412,20 @@ describe Gitlab::ProjectSearchResults do
end
end
end
describe
'user search'
do
let
(
:project
)
{
create
(
:project
)
}
it
'returns the users belonging to the project matching the search query'
do
user1
=
create
(
:user
,
username:
'gob_bluth'
)
create
(
:project_member
,
:developer
,
user:
user1
,
project:
project
)
user2
=
create
(
:user
,
username:
'michael_bluth'
)
create
(
:project_member
,
:developer
,
user:
user2
,
project:
project
)
create
(
:user
,
username:
'gob_2018'
)
expect
(
described_class
.
new
(
user
,
project
,
'gob'
).
objects
(
'users'
)).
to
eq
[
user1
]
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