A platform for community discussion. Free, open, simple.
FIX: embedding topics would fail with some HTML
Sam Saffron2408d5555142
diff --git a/app/models/topic_embed.rb b/app/models/topic_embed.rbindex c1948d89af8..973b4896c51 100644--- a/app/models/topic_embed.rb+++ b/app/models/topic_embed.rb@@ -227,7 +227,7 @@ class TopicEmbed < ActiveRecord::Basereturn result unless result.blank?# If there is no first paragaph, return the first div (onebox)- doc.css('div').first+ doc.css('div').first.to_senddef self.expanded_for(post)diff --git a/spec/models/topic_embed_spec.rb b/spec/models/topic_embed_spec.rbindex 18d4dd97648..1ff69046c0e 100644--- a/spec/models/topic_embed_spec.rb+++ b/spec/models/topic_embed_spec.rb@@ -105,6 +105,16 @@ describe TopicEmbed doexpect(post.raw).to include(long_content)end++ it 'looks at first div when there is no paragraph' do++ no_para = "<div><h>testing it</h></div>"++ SiteSetting.embed_truncate = true+ post = TopicEmbed.import(user, url, title, no_para)++ expect(post.raw).to include("testing it")+ endendend