Commit 992db004 authored by Juan J. Ramirez's avatar Juan J. Ramirez Committed by Martin Wortschack

Code tag styling for search term

add changelog

locale add

Fixing parenthesis method call error

Fixing test for unquoted search term

Fixing failed string tests

Fixing failed tests for new term styling.

Update changelog

Add locale translations

Fix for search_entries_info_template test

Updates to locale

Removing unused slash and adding locales

Adding span and fixing spacing issues

Changing html and locales in search term

Update in test

Refactor to be slightly more secure
parent 620d73bb
......@@ -31,13 +31,14 @@ module SearchHelper
from = collection.offset_value + 1
to = collection.offset_value + collection.to_a.size
count = collection.total_count
term_element = "<span>&nbsp;<code>#{h(term)}</code>&nbsp;</span>".html_safe
search_entries_info_template(collection) % {
from: from,
to: to,
count: count,
scope: search_entries_scope_label(scope, count),
term: term
term_element: term_element
}
end
......@@ -72,9 +73,9 @@ module SearchHelper
def search_entries_info_template(collection)
if collection.total_pages > 1
s_("SearchResults|Showing %{from} - %{to} of %{count} %{scope} for \"%{term}\"")
s_("SearchResults|Showing %{from} - %{to} of %{count} %{scope} for%{term_element}").html_safe
else
s_("SearchResults|Showing %{count} %{scope} for \"%{term}\"")
s_("SearchResults|Showing %{count} %{scope} for%{term_element}").html_safe
end
end
......
---
title: Changes to how the search term is styled in the results
merge_request: 20416
author:
type: changed
......@@ -56,9 +56,9 @@ module EE
return super unless gitlab_com_snippet_db_search?
if collection.total_pages > 1
s_("SearchResults|Showing %{from} - %{to} of %{count} %{scope} for \"%{term}\" in your personal and project snippets")
s_("SearchResults|Showing %{from} - %{to} of %{count} %{scope} for%{term_element} in your personal and project snippets").html_safe
else
s_("SearchResults|Showing %{count} %{scope} for \"%{term}\" in your personal and project snippets")
s_("SearchResults|Showing %{count} %{scope} for%{term_element} in your personal and project snippets").html_safe
end
end
......
......@@ -119,7 +119,7 @@ describe SearchHelper do
let(:show_snippets) { true }
let(:collection) { Kaminari.paginate_array([:foo]).page(1).per(10) }
let(:user) { create(:user) }
let(:message) { "Showing %{count} %{scope} for \"%{term}\"" }
let(:message) { "Showing %{count} %{scope} for%{term_element}" }
let(:new_message) { message + " in your personal and project snippets" }
subject { search_entries_info_template(collection) }
......
......@@ -15325,16 +15325,16 @@ msgstr ""
msgid "SearchCodeResults|of %{link_to_project}"
msgstr ""
msgid "SearchResults|Showing %{count} %{scope} for \"%{term}\""
msgid "SearchResults|Showing %{count} %{scope} for%{term_element}"
msgstr ""
msgid "SearchResults|Showing %{count} %{scope} for \"%{term}\" in your personal and project snippets"
msgid "SearchResults|Showing %{count} %{scope} for%{term_element} in your personal and project snippets"
msgstr ""
msgid "SearchResults|Showing %{from} - %{to} of %{count} %{scope} for \"%{term}\""
msgid "SearchResults|Showing %{from} - %{to} of %{count} %{scope} for%{term_element}"
msgstr ""
msgid "SearchResults|Showing %{from} - %{to} of %{count} %{scope} for \"%{term}\" in your personal and project snippets"
msgid "SearchResults|Showing %{from} - %{to} of %{count} %{scope} for%{term_element} in your personal and project snippets"
msgstr ""
msgid "SearchResults|We couldn't find any %{scope} matching %{term}"
......
......@@ -122,13 +122,13 @@ describe SearchHelper do
it 'uses the correct singular label' do
collection = Kaminari.paginate_array([:foo]).page(1).per(10)
expect(search_entries_info(collection, scope, 'foo')).to eq("Showing 1 #{label} for \"foo\"")
expect(search_entries_info(collection, scope, 'foo')).to eq("Showing 1 #{label} for<span>&nbsp;<code>foo</code>&nbsp;</span>")
end
it 'uses the correct plural label' do
collection = Kaminari.paginate_array([:foo] * 23).page(1).per(10)
expect(search_entries_info(collection, scope, 'foo')).to eq("Showing 1 - 10 of 23 #{label.pluralize} for \"foo\"")
expect(search_entries_info(collection, scope, 'foo')).to eq("Showing 1 - 10 of 23 #{label.pluralize} for<span>&nbsp;<code>foo</code>&nbsp;</span>")
end
end
......
......@@ -16,7 +16,7 @@ describe 'search/_results' do
it 'displays the page size' do
render
expect(rendered).to have_content('Showing 1 - 2 of 3 issues for "foo"')
expect(rendered).to have_content('Showing 1 - 2 of 3 issues for foo')
end
context 'when search results do not have a count' do
......
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