Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/pull/5274'
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Oct 20, 2024
2 parents f7d4fa0 + eaabf7b commit b753a4b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/controllers/diary_entries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def show
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,
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/open_graph_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
11 changes: 11 additions & 0 deletions test/controllers/diary_entries_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,17 @@ def test_show_hidden_comments
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")
Expand Down

0 comments on commit b753a4b

Please sign in to comment.