FIX: Replace details content with instruction.

This commit is contained in:
Bianca Nenciu
2019-05-24 18:57:03 +03:00
committed by Guo Xiang Tan
parent 6cceb72173
commit 3a1d99577e
3 changed files with 27 additions and 3 deletions

View File

@ -5,6 +5,8 @@ require 'pretty_text'
describe PrettyText do
let(:post) { Fabricate(:post) }
it "supports details tag" do
cooked_html = <<~HTML
<details>
@ -20,9 +22,23 @@ describe PrettyText do
it "deletes elided content" do
cooked_html = PrettyText.cook("Hello World\n\n<details class='elided'>42</details>")
mail_html = PrettyText.cook("Hello World")
mail_html = "<p>Hello World</p>\n<a href=\"http://test.localhost\">(click for more details)</a>"
expect(PrettyText.format_for_email(cooked_html)).to match_html(mail_html)
end
it 'can replace spoilers in emails' do
md = PrettyText.cook(<<~EOF)
hello
[details="Summary"]
world
[/details]
EOF
md = PrettyText.format_for_email(md, post)
html = "<p>hello</p>\n\nSummary <a href=\"#{post.full_url}\">(click for more details)</a>"
expect(md).to eq(html)
end
end