Skip to content
Extraits de code Groupes Projets
Valider 731adffa rédigé par Steffen van Bergerem's avatar Steffen van Bergerem
Parcourir les fichiers

Merge pull request #5497 from jhass/og_reshare_fix

Handle reshares of deleted posts in OpenGraph tags generation code
parents 6c9f1916 45b385d6
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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
......
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" => {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter