Skip to content

A platform for community discussion. Free, open, simple.

DEV: Add test for poll plugin reduce_excerpt.

Bianca Nenciu63e3d4950879
diff --git a/plugins/poll/spec/lib/pretty_text_spec.rb b/plugins/poll/spec/lib/pretty_text_spec.rb
index a1b834ac7ca..7dbcd2e2302 100644
--- a/plugins/poll/spec/lib/pretty_text_spec.rb
+++ b/plugins/poll/spec/lib/pretty_text_spec.rb
@@ -136,4 +136,21 @@ describe PrettyText do
expect(onebox[:preview]).to include("A post with a poll")
expect(onebox[:preview]).to include("<a href=\"#{post.url}\">poll</a>")
end
+
+ it 'can reduce excerpts' do
+ post = Fabricate(:post, raw: <<~EOF)
+ A post with a poll
+
+ [poll type=regular]
+ * Hello
+ * World
+ [/poll]
+ EOF
+
+ excerpt = PrettyText.excerpt(post.cooked, SiteSetting.post_onebox_maxlength, post: post)
+ expect(excerpt).to eq("A post with a poll \n<a href=\"#{post.url}\">poll</a>")
+
+ excerpt = PrettyText.excerpt(post.cooked, SiteSetting.post_onebox_maxlength)
+ expect(excerpt).to eq("A post with a poll \npoll")
+ end
end