DEV: output sitelinks search tag on homepage only (#16157)

Output sitelinks search tag on homepage only
This commit is contained in:
Ayke Halder
2022-09-23 09:05:53 +02:00
committed by GitHub
parent 8c7a38449c
commit 7277a9fbb3
2 changed files with 51 additions and 10 deletions

View File

@ -100,6 +100,45 @@ RSpec.describe ApplicationHelper do
end
end
describe "render_sitelinks_search_tag" do
context "for non-subfolder install" do
context "when on homepage" do
it "will return sitelinks search tag" do
helper.stubs(:current_page?).returns(false)
helper.stubs(:current_page?).with('/').returns(true)
expect(helper.render_sitelinks_search_tag).to include('"@type":"SearchAction"')
end
end
context "when not on homepage" do
it "will not return sitelinks search tag" do
helper.stubs(:current_page?).returns(true)
helper.stubs(:current_page?).with('/').returns(false)
helper.stubs(:current_page?).with(Discourse.base_path).returns(false)
expect(helper.render_sitelinks_search_tag).to be_nil
end
end
end
context "for subfolder install" do
context "when on homepage" do
it "will return sitelinks search tag" do
Discourse.stubs(:base_path).returns('/subfolder-base-path/')
helper.stubs(:current_page?).returns(false)
helper.stubs(:current_page?).with(Discourse.base_path).returns(true)
expect(helper.render_sitelinks_search_tag).to include('"@type":"SearchAction"')
end
end
context "when not on homepage" do
it "will not return sitelinks search tag" do
Discourse.stubs(:base_path).returns('/subfolder-base-path/')
helper.stubs(:current_page?).returns(true)
helper.stubs(:current_page?).with('/').returns(false)
helper.stubs(:current_page?).with(Discourse.base_path).returns(false)
expect(helper.render_sitelinks_search_tag).to be_nil
end
end
end
end
describe "application_logo_url" do
context "when a dark color scheme is active" do
before do