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
df6a2a94
Commit
df6a2a94
authored
Jun 22, 2021
by
Dmitry Gruzd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Search: add ability to sort epics
Changelog: changed EE: true
parent
e6928e1d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
36 deletions
+35
-36
app/presenters/search_service_presenter.rb
app/presenters/search_service_presenter.rb
+1
-1
ee/lib/ee/gitlab/group_search_results.rb
ee/lib/ee/gitlab/group_search_results.rb
+3
-2
ee/lib/ee/gitlab/search_results.rb
ee/lib/ee/gitlab/search_results.rb
+0
-6
ee/spec/lib/ee/gitlab/group_search_results_spec.rb
ee/spec/lib/ee/gitlab/group_search_results_spec.rb
+31
-11
ee/spec/lib/ee/gitlab/search_results_spec.rb
ee/spec/lib/ee/gitlab/search_results_spec.rb
+0
-16
No files found.
app/presenters/search_service_presenter.rb
View file @
df6a2a94
...
...
@@ -16,7 +16,7 @@ class SearchServicePresenter < Gitlab::View::Presenter::Delegated
blobs: :with_web_entity_associations
}.
freeze
SORT_ENABLED_SCOPES
=
%w(issues merge_requests)
.
freeze
SORT_ENABLED_SCOPES
=
%w(issues merge_requests
epics
)
.
freeze
def
search_objects
@search_objects
||=
begin
...
...
ee/lib/ee/gitlab/group_search_results.rb
View file @
df6a2a94
...
...
@@ -5,9 +5,10 @@ module EE
module
GroupSearchResults
extend
::
Gitlab
::
Utils
::
Override
override
:epics
def
epics
EpicsFinder
.
new
(
current_user
,
issuable_params
).
execute
.
search
(
query
)
epics
=
EpicsFinder
.
new
(
current_user
,
issuable_params
).
execute
.
search
(
query
)
apply_sort
(
epics
)
end
end
end
...
...
ee/lib/ee/gitlab/search_results.rb
View file @
df6a2a94
...
...
@@ -15,12 +15,6 @@ module EE
end
end
def
epics
groups_finder
=
GroupsFinder
.
new
(
current_user
)
::
Epic
.
in_selected_groups
(
groups_finder
.
execute
).
search
(
query
)
end
private
override
:projects
...
...
ee/spec/lib/ee/gitlab/group_search_results_spec.rb
View file @
df6a2a94
...
...
@@ -8,20 +8,40 @@ RSpec.describe Gitlab::GroupSearchResults do
subject
{
described_class
.
new
(
user
,
query
,
group:
group
)
}
before
do
create
(
:group_member
,
group:
group
,
user:
user
)
group
.
add_owner
(
user
)
stub_licensed_features
(
epics:
true
)
end
describe
'#epics'
do
let
(
:query
)
{
'foo'
}
let!
(
:searchable_epic
)
{
create
(
:epic
,
title:
'foo'
,
group:
group
)
}
let!
(
:another_searchable_epic
)
{
create
(
:epic
,
title:
'foo 2
'
,
group:
group
)
}
let!
(
:another_epic
)
{
create
(
:epic
)
}
before
do
create
(
:group_member
,
group:
group
,
user:
user
)
group
.
add_owner
(
user
)
stub_licensed_features
(
epics:
true
)
context
'searching'
do
let
(
:query
)
{
'foo'
}
let!
(
:searchable_epic
)
{
create
(
:epic
,
title:
'foo
'
,
group:
group
)
}
let!
(
:another_searchable_epic
)
{
create
(
:epic
,
title:
'foo 2'
,
group:
group
)
}
let!
(
:another_epic
)
{
create
(
:epic
)
}
it
'finds epics'
do
expect
(
subject
.
objects
(
'epics'
)).
to
match_array
([
searchable_epic
,
another_searchable_epic
]
)
end
end
it
'finds epics'
do
expect
(
subject
.
objects
(
'epics'
)).
to
match_array
([
searchable_epic
,
another_searchable_epic
])
context
'ordering'
do
let
(
:scope
)
{
'epics'
}
let
(
:filters
)
{
{}
}
let!
(
:old_result
)
{
create
(
:epic
,
group:
group
,
title:
'sorted old'
,
created_at:
1
.
month
.
ago
)
}
let!
(
:new_result
)
{
create
(
:epic
,
group:
group
,
title:
'sorted recent'
,
created_at:
1
.
day
.
ago
)
}
let!
(
:very_old_result
)
{
create
(
:epic
,
group:
group
,
title:
'sorted very old'
,
created_at:
1
.
year
.
ago
)
}
let!
(
:old_updated
)
{
create
(
:epic
,
group:
group
,
title:
'updated old'
,
updated_at:
1
.
month
.
ago
)
}
let!
(
:new_updated
)
{
create
(
:epic
,
group:
group
,
title:
'updated recent'
,
updated_at:
1
.
day
.
ago
)
}
let!
(
:very_old_updated
)
{
create
(
:epic
,
group:
group
,
title:
'updated very old'
,
updated_at:
1
.
year
.
ago
)
}
include_examples
'search results sorted'
do
let
(
:results_created
)
{
described_class
.
new
(
user
,
'sorted'
,
Project
.
order
(
:id
),
group:
group
,
sort:
sort
,
filters:
filters
)
}
let
(
:results_updated
)
{
described_class
.
new
(
user
,
'updated'
,
Project
.
order
(
:id
),
group:
group
,
sort:
sort
,
filters:
filters
)
}
end
end
end
end
ee/spec/lib/ee/gitlab/search_results_spec.rb
View file @
df6a2a94
...
...
@@ -24,22 +24,6 @@ RSpec.describe Gitlab::SearchResults do
end
end
describe
'#epics'
do
let!
(
:group
)
{
create
(
:group
,
:private
)
}
let!
(
:searchable_epic
)
{
create
(
:epic
,
title:
'foo'
,
group:
group
)
}
let!
(
:another_group
)
{
create
(
:group
,
:private
)
}
let!
(
:another_epic
)
{
create
(
:epic
,
title:
'foo 2'
,
group:
another_group
)
}
before
do
create
(
:group_member
,
group:
group
,
user:
user
)
group
.
add_owner
(
user
)
end
it
'finds epics'
do
expect
(
subject
.
objects
(
'epics'
)).
to
match_array
([
searchable_epic
])
end
end
def
search
subject
.
objects
(
'projects'
).
map
{
|
project
|
project
.
compliance_framework_setting
.
framework
}
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