DEV: Add test for poll plugin reduce_excerpt.

This commit is contained in:
Bianca Nenciu 2019-06-03 19:58:26 +03:00 committed by Guo Xiang Tan
parent 2863e7c181
commit 63e3d49508
1 changed files with 17 additions and 0 deletions

View File

@ -136,4 +136,21 @@ describe PrettyText do
expect(onebox[:preview]).to include("A post with a poll") expect(onebox[:preview]).to include("A post with a poll")
expect(onebox[:preview]).to include("<a href=\"#{post.url}\">poll</a>") expect(onebox[:preview]).to include("<a href=\"#{post.url}\">poll</a>")
end 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 end