reflect search query in page title (#15434)
This commit is contained in:
parent
50f8cb21fc
commit
e5cda63391
4 changed files with 33 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
|||
<% title t("views.search.meta.title") %>
|
||||
<% title t("views.search.meta.title", for: (params[:q].present? ? t("views.search.meta.for", query: params[:q]) : "")) %>
|
||||
|
||||
<link rel="canonical" href="<%= app_url(search_path) %>" />
|
||||
<meta name="description" content="<%= Settings::Community.community_description %>">
|
||||
<%= meta_keywords_default %>
|
||||
|
|
|
|||
|
|
@ -85,7 +85,8 @@ en:
|
|||
newest: Newest
|
||||
oldest: Oldest
|
||||
meta:
|
||||
title: Search Results
|
||||
title: Search Results%{for}
|
||||
for: " for %{query}"
|
||||
description: "%{site} => Search Results"
|
||||
series:
|
||||
meta:
|
||||
|
|
|
|||
|
|
@ -85,7 +85,8 @@ fr:
|
|||
newest: Newest
|
||||
oldest: Oldest
|
||||
meta:
|
||||
title: Search Results
|
||||
title: Search Results%{for}
|
||||
for: " for %{query}"
|
||||
description: "%{site} => Search Results"
|
||||
series:
|
||||
meta:
|
||||
|
|
|
|||
27
spec/system/search/search_title_spec.rb
Normal file
27
spec/system/search/search_title_spec.rb
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe "Search page title", type: :system do
|
||||
let!(:current_user) { create(:user) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
context "when search query param exists" do
|
||||
it "includes the search term in title and heading" do
|
||||
visit "/search?q=helloworld"
|
||||
|
||||
expect(page).to have_title("Search Results for helloworld - DEV(local)")
|
||||
expect(page.find("h1")).to have_content("Search results for helloworld")
|
||||
end
|
||||
end
|
||||
|
||||
context "when search query param doesn't exist" do
|
||||
it "does not include search term in title and heading" do
|
||||
visit "/search"
|
||||
|
||||
expect(page).to have_title("Search Results - DEV(local)")
|
||||
expect(page.find("h1")).to have_content("Search results")
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue