Commit a5b71685 authored by Dmitry Gruzd's avatar Dmitry Gruzd

Fix basic search full count load

Changelog: fixed
parent e58a4257
......@@ -39,6 +39,7 @@ class SearchController < ApplicationController
@search_service = Gitlab::View::Presenter::Factory.new(search_service, current_user: current_user).fabricate!
@scope = @search_service.scope
@without_count = @search_service.without_count?
@show_snippets = @search_service.show_snippets?
@search_results = @search_service.search_results
@search_objects = @search_service.search_objects
......
......@@ -9,7 +9,10 @@
- project_attributes = @project&.attributes&.slice('id', 'namespace_id', 'name')&.merge(name_with_namespace: @project&.name_with_namespace)
- if @search_results
- page_description(_("%{count} %{scope} for term '%{term}'") % { count: @search_results.formatted_count(@scope), scope: @scope, term: @search_term })
- if @without_count
- page_description(_("%{scope} results for term '%{term}'") % { scope: @scope, term: @search_term })
- else
- page_description(_("%{count} %{scope} for term '%{term}'") % { count: @search_results.formatted_count(@scope), scope: @scope, term: @search_term })
- page_card_attributes("Namespace" => @group&.full_path, "Project" => @project&.full_path)
.page-title-holder.d-flex.flex-wrap.justify-content-between
......
......@@ -24,7 +24,7 @@ module Gitlab
when 'users'
users.page(page).per(per_page)
else
super(scope, page: page, per_page: per_page, without_count: false)
super(scope, page: page, per_page: per_page, without_count: true)
end
end
......
......@@ -835,6 +835,9 @@ msgstr ""
msgid "%{rotation} has been recalculated with the remaining participants. Please review the new setup for %{rotation}. It is recommended that you reach out to the current on-call responder to ensure continuity of on-call coverage."
msgstr ""
msgid "%{scope} results for term '%{term}'"
msgstr ""
msgid "%{seconds}s"
msgstr ""
......
......@@ -33,6 +33,10 @@ RSpec.describe Gitlab::SearchResults do
expect(results.objects('projects', page: 1, per_page: 1, without_count: false)).not_to be_kind_of(Kaminari::PaginatableWithoutCount)
end
it 'returns without counts collection when requested' do
expect(results.objects('projects', page: 1, per_page: 1, without_count: true)).to be_kind_of(Kaminari::PaginatableWithoutCount)
end
it 'uses page and per_page to paginate results' do
project2 = create(:project, name: 'foo')
......
......@@ -48,21 +48,50 @@ RSpec.describe 'search/show' do
assign(:group, group)
end
it 'renders meta tags for a group' do
render
context 'search with full count' do
before do
assign(:without_count, false)
end
it 'renders meta tags for a group' do
render
expect(view.page_description).to match(/\d+ issues for term '#{search_term}'/)
expect(view.page_card_attributes).to eq("Namespace" => group.full_path)
end
expect(view.page_description).to match(/\d+ issues for term '#{search_term}'/)
expect(view.page_card_attributes).to eq("Namespace" => group.full_path)
it 'renders meta tags for both group and project' do
project = build(:project, group: group)
assign(:project, project)
render
expect(view.page_description).to match(/\d+ issues for term '#{search_term}'/)
expect(view.page_card_attributes).to eq("Namespace" => group.full_path, "Project" => project.full_path)
end
end
it 'renders meta tags for both group and project' do
project = build(:project, group: group)
assign(:project, project)
context 'search without full count' do
before do
assign(:without_count, true)
end
it 'renders meta tags for a group' do
render
expect(view.page_description).to match(/issues results for term '#{search_term}'/)
expect(view.page_card_attributes).to eq("Namespace" => group.full_path)
end
it 'renders meta tags for both group and project' do
project = build(:project, group: group)
assign(:project, project)
render
render
expect(view.page_description).to match(/\d+ issues for term '#{search_term}'/)
expect(view.page_card_attributes).to eq("Namespace" => group.full_path, "Project" => project.full_path)
expect(view.page_description).to match(/issues results for term '#{search_term}'/)
expect(view.page_card_attributes).to eq("Namespace" => group.full_path, "Project" => project.full_path)
end
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment