]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/diary_entries_controller_test.rb
Merge remote-tracking branch 'upstream/pull/5288'
[rails.git] / test / controllers / diary_entries_controller_test.rb
index ced241a7f8456072532b3906986565831b070fec..7d543250bc88a17b565cc72d99196d3f4b48a16d 100644 (file)
@@ -648,6 +648,17 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest
     end
   end
 
+  def test_show_og_title
+    user = create(:user)
+    diary_entry = create(:diary_entry, :user => user, :title => "The Important Blog Post")
+
+    get diary_entry_path(user, diary_entry)
+    assert_response :success
+    assert_dom "head meta[property='og:title']" do
+      assert_dom "> @content", "The Important Blog Post"
+    end
+  end
+
   def test_show_og_image_with_no_image
     user = create(:user)
     diary_entry = create(:diary_entry, :user => user, :body => "nothing")
@@ -744,6 +755,39 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest
     assert_dom "head meta[property='og:image:alt']", :count => 0
   end
 
+  def test_show_no_og_description
+    user = create(:user)
+    diary_entry = create(:diary_entry, :user => user, :body => "![nope](https://example.com/nope.jpg)")
+
+    get diary_entry_path(user, diary_entry)
+    assert_response :success
+    assert_dom "head meta[property='og:description']" do
+      assert_dom "> @content", I18n.t("layouts.intro_text")
+    end
+  end
+
+  def test_show_og_description
+    user = create(:user)
+    diary_entry = create(:diary_entry, :user => user, :body => "# Hello\n\n![hello](https://example.com/hello.jpg)\n\nFirst paragraph.\n\nSecond paragraph.")
+
+    get diary_entry_path(user, diary_entry)
+    assert_response :success
+    assert_dom "head meta[property='og:description']" do
+      assert_dom "> @content", "First paragraph."
+    end
+  end
+
+  def test_show_article_published_time
+    user = create(:user)
+    diary_entry = create(:diary_entry, :user => user, :created_at => "2020-03-04")
+
+    get diary_entry_path(user, diary_entry)
+    assert_response :success
+    assert_dom "head meta[property='article:published_time']" do
+      assert_dom "> @content", "2020-03-04T00:00:00Z"
+    end
+  end
+
   def test_hide
     user = create(:user)
     diary_entry = create(:diary_entry, :user => user)