Merge remote-tracking branch 'upstream/pull/5274'
This commit is contained in:
commit
b753a4bf05
3 changed files with 13 additions and 1 deletions
|
@ -71,6 +71,7 @@ class DiaryEntriesController < ApplicationController
|
|||
if @entry
|
||||
@title = t ".title", :user => params[:display_name], :title => @entry.title
|
||||
@opengraph_properties = {
|
||||
"og:title" => @entry.title,
|
||||
"og:image" => @entry.body.image,
|
||||
"og:image:alt" => @entry.body.image_alt,
|
||||
"og:description" => @entry.body.description,
|
||||
|
|
|
@ -4,7 +4,7 @@ module OpenGraphHelper
|
|||
def opengraph_tags(title, properties)
|
||||
tags = {
|
||||
"og:site_name" => t("layouts.project_name.title"),
|
||||
"og:title" => title || t("layouts.project_name.title"),
|
||||
"og:title" => properties["og:title"] || title || t("layouts.project_name.title"),
|
||||
"og:type" => "website",
|
||||
"og:url" => url_for(:only_path => false),
|
||||
"og:description" => properties["og:description"] || t("layouts.intro_text")
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue