Use correct title in og:title for pages with no title
authorTom Hughes <tom@compton.nu>
Mon, 7 Dec 2015 15:54:06 +0000 (15:54 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 7 Dec 2015 15:54:06 +0000 (15:54 +0000)
Fixes #1098

app/helpers/title_helper.rb
test/helpers/title_helper_test.rb

index eb1724d93aac343ae23a559111b7317a3b4785fd..8b1eb53b6dfdcae08ea8291a4c2d393ed1b7bad0 100644 (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)
index d07a5bd0707dc9cdb6698f3e99753638a1a1d183..523313eaf64f36e71fc2b38f54f6dc7772f472a8 100644 (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