From 03356be5887ec2075f68e42bf8fa0928fa0ce249 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 7 Dec 2015 15:54:06 +0000 Subject: [PATCH] Use correct title in og:title for pages with no title Fixes #1098 --- app/helpers/title_helper.rb | 2 +- test/helpers/title_helper_test.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/helpers/title_helper.rb b/app/helpers/title_helper.rb index eb1724d93..8b1eb53b6 100644 --- a/app/helpers/title_helper.rb +++ b/app/helpers/title_helper.rb @@ -5,7 +5,7 @@ module TitleHelper @coder ||= HTMLEntities.new end - def set_title(title = false) + def set_title(title = nil) if title @title = TitleHelper.coder.decode(title.gsub("", "\u202a").gsub("", "\u202c")) response.headers["X-Page-Title"] = URI.escape(t("layouts.project_name.title") + " | " + @title) diff --git a/test/helpers/title_helper_test.rb b/test/helpers/title_helper_test.rb index d07a5bd07..523313eaf 100644 --- a/test/helpers/title_helper_test.rb +++ b/test/helpers/title_helper_test.rb @@ -3,6 +3,10 @@ require "test_helper" class TitleHelperTest < ActionView::TestCase def test_set_title + set_title + assert_equal "OpenStreetMap", response.header["X-Page-Title"] + assert_nil @title + set_title(nil) assert_equal "OpenStreetMap", response.header["X-Page-Title"] assert_nil @title -- 2.39.5