X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/243557a31aec5012796821fda6f2702a5e1efdae..563871c5a9a8140522b0c569df5c91a38528c8ce:/test/controllers/diary_entries_controller_test.rb diff --git a/test/controllers/diary_entries_controller_test.rb b/test/controllers/diary_entries_controller_test.rb index e3bbb490d..aad759b5b 100644 --- a/test/controllers/diary_entries_controller_test.rb +++ b/test/controllers/diary_entries_controller_test.rb @@ -163,7 +163,7 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest :longitude => "2.2", :language_code => "en" }) end assert_redirected_to :action => :index, :display_name => user.display_name - entry = DiaryEntry.order(:id).last + entry = DiaryEntry.last assert_equal user.id, entry.user_id assert_equal "New Title", entry.title assert_equal "This is a new body for the diary entry", entry.body @@ -189,7 +189,7 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest :longitude => "2.2", :language_code => "de" }) end assert_redirected_to :action => :index, :display_name => user.display_name - entry = DiaryEntry.order(:id).last + entry = DiaryEntry.last assert_equal user.id, entry.user_id assert_equal "New Title", entry.title assert_equal "This is a new body for the diary entry", entry.body @@ -217,7 +217,7 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest :diary_entry => { :title => spammy_title, :body => spammy_body, :language_code => "en" }) end assert_redirected_to :action => :index, :display_name => user.display_name - entry = DiaryEntry.order(:id).last + entry = DiaryEntry.last assert_equal user.id, entry.user_id assert_equal spammy_title, entry.title assert_equal spammy_body, entry.body @@ -744,6 +744,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)