Use correct title in og:title for pages with no title

Fixes #1098
This commit is contained in:
Tom Hughes 2015-12-07 15:54:06 +00:00
parent 8368f90310
commit 03356be588
2 changed files with 5 additions and 1 deletions

View file

@ -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("<bdi>", "\u202a").gsub("</bdi>", "\u202c"))
response.headers["X-Page-Title"] = URI.escape(t("layouts.project_name.title") + " | " + @title)

View file

@ -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