X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/eab4eec59eb6b1bf7f1ed6f552e17450a620223f..ea7b19c8fa71089bdc4a33b30f6ecf6e9fda7dfb:/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 4eeeb2742..d0453bf08 100644 --- a/test/controllers/diary_entries_controller_test.rb +++ b/test/controllers/diary_entries_controller_test.rb @@ -736,6 +736,17 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest end end + def test_show_og_image_with_no_image + user = create(:user) + diary_entry = create(:diary_entry, :user => user, :body => "nothing") + + get diary_entry_path(user, diary_entry) + assert_response :success + assert_dom "head meta[property='og:image']" do + assert_dom "> @content", ActionController::Base.helpers.image_url("osm_logo_256.png", :host => root_url) + end + end + def test_show_og_image user = create(:user) diary_entry = create(:diary_entry, :user => user, :body => "![some picture](https://example.com/picture.jpg)") @@ -758,6 +769,39 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest end end + def test_show_og_image_with_spaces + user = create(:user) + diary_entry = create(:diary_entry, :user => user, :body => "![some picture](https://example.com/the picture.jpg)") + + get diary_entry_path(user, diary_entry) + assert_response :success + assert_dom "head meta[property='og:image']" do + assert_dom "> @content", "https://example.com/the%20picture.jpg" + end + end + + def test_show_og_image_with_relative_uri_and_spaces + user = create(:user) + diary_entry = create(:diary_entry, :user => user, :body => "![some local picture](/the picture.jpg)") + + get diary_entry_path(user, diary_entry) + assert_response :success + assert_dom "head meta[property='og:image']" do + assert_dom "> @content", "#{root_url}the%20picture.jpg" + end + end + + def test_show_og_image_with_invalid_uri + user = create(:user) + diary_entry = create(:diary_entry, :user => user, :body => "![](:)") + + get diary_entry_path(user, diary_entry) + assert_response :success + assert_dom "head meta[property='og:image']" do + assert_dom "> @content", ActionController::Base.helpers.image_url("osm_logo_256.png", :host => root_url) + end + end + def test_hide user = create(:user) diary_entry = create(:diary_entry, :user => user)