: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
: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
: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
assert_dom "head meta[property='og:image']" do
assert_dom "> @content", ActionController::Base.helpers.image_url("osm_logo_256.png", :host => root_url)
end
+ assert_dom "head meta[property='og:image:alt']" do
+ assert_dom "> @content", "OpenStreetMap logo"
+ end
end
def test_show_og_image
assert_dom "head meta[property='og:image']" do
assert_dom "> @content", "https://example.com/picture.jpg"
end
+ assert_dom "head meta[property='og:image:alt']" do
+ assert_dom "> @content", "some picture"
+ end
end
def test_show_og_image_with_relative_uri
assert_dom "head meta[property='og:image']" do
assert_dom "> @content", "#{root_url}picture.jpg"
end
+ assert_dom "head meta[property='og:image:alt']" do
+ assert_dom "> @content", "some local picture"
+ end
end
def test_show_og_image_with_spaces
assert_dom "head meta[property='og:image']" do
assert_dom "> @content", "https://example.com/the%20picture.jpg"
end
+ assert_dom "head meta[property='og:image:alt']" do
+ assert_dom "> @content", "some picture"
+ end
end
def test_show_og_image_with_relative_uri_and_spaces
assert_dom "head meta[property='og:image']" do
assert_dom "> @content", "#{root_url}the%20picture.jpg"
end
+ assert_dom "head meta[property='og:image:alt']" do
+ assert_dom "> @content", "some local picture"
+ end
end
def test_show_og_image_with_invalid_uri
assert_dom "head meta[property='og:image']" do
assert_dom "> @content", ActionController::Base.helpers.image_url("osm_logo_256.png", :host => root_url)
end
+ assert_dom "head meta[property='og:image:alt']" do
+ assert_dom "> @content", "OpenStreetMap logo"
+ end
+ end
+
+ def test_show_og_image_without_alt
+ user = create(:user)
+ diary_entry = create(:diary_entry, :user => user, :body => "<img src='https://example.com/no_alt.gif'>")
+
+ get diary_entry_path(user, diary_entry)
+ assert_response :success
+ assert_dom "head meta[property='og:image']" do
+ assert_dom "> @content", "https://example.com/no_alt.gif"
+ end
+ assert_dom "head meta[property='og:image:alt']", :count => 0
end
def test_hide