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
Boxiang Sun
gitlab-ce
Commits
a8818bab
Commit
a8818bab
authored
Aug 15, 2018
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add users search results to group scoped search
parent
a52d1dbb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
0 deletions
+84
-0
app/services/search/group_service.rb
app/services/search/group_service.rb
+6
-0
lib/gitlab/group_search_results.rb
lib/gitlab/group_search_results.rb
+17
-0
spec/features/search/user_searches_for_users_spec.rb
spec/features/search/user_searches_for_users_spec.rb
+30
-0
spec/lib/gitlab/group_search_results_spec.rb
spec/lib/gitlab/group_search_results_spec.rb
+31
-0
No files found.
app/services/search/group_service.rb
View file @
a8818bab
...
...
@@ -11,6 +11,12 @@ module Search
@group
=
group
end
def
execute
Gitlab
::
GroupSearchResults
.
new
(
current_user
,
projects
,
group
,
params
[
:search
],
default_project_filter:
default_project_filter
)
end
def
projects
return
Project
.
none
unless
group
return
@projects
if
defined?
@projects
...
...
lib/gitlab/group_search_results.rb
0 → 100644
View file @
a8818bab
# frozen_string_literal: true
module
Gitlab
class
GroupSearchResults
<
SearchResults
def
initialize
(
current_user
,
limit_projects
,
group
,
query
,
default_project_filter:
false
,
per_page:
20
)
super
(
current_user
,
limit_projects
,
query
,
default_project_filter:
default_project_filter
,
per_page:
per_page
)
@group
=
group
end
# rubocop:disable CodeReuse/ActiveRecord
def
users
super
.
where
(
id:
@group
.
users_with_descendants
)
end
# rubocop:enable CodeReuse/ActiveRecord
end
end
spec/features/search/user_searches_for_users_spec.rb
View file @
a8818bab
...
...
@@ -50,4 +50,34 @@ describe 'User searches for users' do
expect
(
page
).
not_to
have_content
(
'@gob_2018'
)
end
end
context
'when on the group page'
do
it
'finds the user belonging to the group'
do
group
=
create
(
:group
)
user1
=
create
(
:user
,
username:
'gob_bluth'
,
name:
'Gob Bluth'
)
create
(
:group_member
,
:developer
,
user:
user1
,
group:
group
)
user2
=
create
(
:user
,
username:
'michael_bluth'
,
name:
'Michael Bluth'
)
create
(
:group_member
,
:developer
,
user:
user2
,
group:
group
)
create
(
:user
,
username:
'gob_2018'
,
name:
'George Oscar Bluth'
)
sign_in
(
user1
)
visit
group_path
(
group
)
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/group_search_results_spec.rb
0 → 100644
View file @
a8818bab
require
'spec_helper'
describe
Gitlab
::
GroupSearchResults
do
let
(
:user
)
{
create
(
:user
)
}
describe
'user search'
do
let
(
:group
)
{
create
(
:group
)
}
it
'returns the users belonging to the group matching the search query'
do
user1
=
create
(
:user
,
username:
'gob_bluth'
)
create
(
:group_member
,
:developer
,
user:
user1
,
group:
group
)
user2
=
create
(
:user
,
username:
'michael_bluth'
)
create
(
:group_member
,
:developer
,
user:
user2
,
group:
group
)
create
(
:user
,
username:
'gob_2018'
)
expect
(
described_class
.
new
(
user
,
anything
,
group
,
'gob'
).
objects
(
'users'
)).
to
eq
[
user1
]
end
it
'returns the user belonging to the subgroup matching the search query'
,
:nested_groups
do
user1
=
create
(
:user
,
username:
'gob_bluth'
)
subgroup
=
create
(
:group
,
parent:
group
)
create
(
:group_member
,
:developer
,
user:
user1
,
group:
subgroup
)
create
(
:user
,
username:
'gob_2018'
)
expect
(
described_class
.
new
(
user
,
anything
,
group
,
'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