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
2b309e39
Commit
2b309e39
authored
Mar 11, 2022
by
John Mason
Committed by
Sean McGivern
Mar 11, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Search presenter is a noop when given empty results
Changelog: changed
parent
f480be75
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
+22
-2
app/presenters/search_service_presenter.rb
app/presenters/search_service_presenter.rb
+1
-1
spec/presenters/search_service_presenter_spec.rb
spec/presenters/search_service_presenter_spec.rb
+21
-1
No files found.
app/presenters/search_service_presenter.rb
View file @
2b309e39
...
@@ -25,7 +25,7 @@ class SearchServicePresenter < Gitlab::View::Presenter::Delegated
...
@@ -25,7 +25,7 @@ class SearchServicePresenter < Gitlab::View::Presenter::Delegated
case
scope
case
scope
when
'users'
when
'users'
objects
.
eager_load
(
:status
)
# rubocop:disable CodeReuse/ActiveRecord
objects
.
eager_load
(
:status
)
if
objects
.
respond_to?
(
:eager_load
)
# rubocop:disable CodeReuse/ActiveRecord
when
'commits'
when
'commits'
prepare_commits_for_rendering
(
objects
)
prepare_commits_for_rendering
(
objects
)
else
else
...
...
spec/presenters/search_service_presenter_spec.rb
View file @
2b309e39
...
@@ -4,13 +4,33 @@ require 'spec_helper'
...
@@ -4,13 +4,33 @@ require 'spec_helper'
RSpec
.
describe
SearchServicePresenter
do
RSpec
.
describe
SearchServicePresenter
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:search
)
{
''
}
let
(
:search_service
)
{
SearchService
.
new
(
user
,
search:
search
,
scope:
scope
)
}
let
(
:search_service
)
{
SearchService
.
new
(
user
,
search:
search
,
scope:
scope
)
}
let
(
:presenter
)
{
described_class
.
new
(
search_service
,
current_user:
user
)
}
let
(
:presenter
)
{
described_class
.
new
(
search_service
,
current_user:
user
)
}
describe
'#search_objects'
do
let
(
:search_objects
)
{
Kaminari
::
PaginatableArray
.
new
([])
}
context
'objects do not respond to eager_load'
do
before
do
allow
(
search_service
).
to
receive
(
:search_objects
).
and_return
(
search_objects
)
allow
(
search_objects
).
to
receive
(
:respond_to?
).
with
(
:eager_load
).
and_return
(
false
)
end
context
'users scope'
do
let
(
:scope
)
{
'users'
}
it
'does not eager load anything'
do
expect
(
search_objects
).
not_to
receive
(
:eager_load
)
presenter
.
search_objects
end
end
end
end
describe
'#show_results_status?'
do
describe
'#show_results_status?'
do
using
RSpec
::
Parameterized
::
TableSyntax
using
RSpec
::
Parameterized
::
TableSyntax
let
(
:search
)
{
''
}
let
(
:scope
)
{
nil
}
let
(
:scope
)
{
nil
}
before
do
before
do
...
...
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