Merge pull request #5497 from jhass/og_reshare_fix
Handle reshares of deleted posts in OpenGraph tags generation code
This commit is contained in:
commit
731adffa78
2 changed files with 30 additions and 8 deletions
|
|
@ -50,14 +50,21 @@ module OpenGraphHelper
|
|||
end
|
||||
|
||||
def og_page_post_tags(post)
|
||||
[
|
||||
*og_common_tags,
|
||||
og_type("#{og_namespace}:frame"),
|
||||
og_title(post_page_title(post, :length => 140)),
|
||||
og_url(post_url(post)),
|
||||
og_image(post),
|
||||
og_description(post.message.plain_text_without_markdown truncate: 1000)
|
||||
].join("\n").html_safe
|
||||
tags = og_common_tags
|
||||
|
||||
|
||||
if post.message
|
||||
tags.concat [
|
||||
*tags,
|
||||
og_type("#{og_namespace}:frame"),
|
||||
og_title(post_page_title(post, :length => 140)),
|
||||
og_url(post_url(post)),
|
||||
og_image(post),
|
||||
og_description(post.message.plain_text_without_markdown truncate: 1000)
|
||||
]
|
||||
end
|
||||
|
||||
tags.join("\n").html_safe
|
||||
end
|
||||
|
||||
def og_prefix
|
||||
|
|
|
|||
|
|
@ -1,6 +1,21 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe OpenGraphHelper, :type => :helper do
|
||||
describe 'og_page_post_tags' do
|
||||
it 'handles a reshare of a deleted post' do
|
||||
reshare = FactoryGirl.build(:reshare, root: nil, id: 123)
|
||||
|
||||
expect {
|
||||
helper.og_page_post_tags(reshare)
|
||||
}.to_not raise_error
|
||||
end
|
||||
|
||||
it 'handles a normal post' do
|
||||
post = FactoryGirl.create(:status_message)
|
||||
expect(helper.og_page_post_tags(post)).to include helper.og_url(post_url(post))
|
||||
end
|
||||
end
|
||||
|
||||
describe 'og_html' do
|
||||
scenarios = {
|
||||
"article" => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue