diaspora/spec/lib/diaspora/markdownify_email_spec.rb
Steffen van Bergerem fdad348898 Fix tag rendering in emails
closes #6009
2015-05-31 01:47:05 +02:00

36 lines
1.2 KiB
Ruby

require 'spec_helper'
describe Diaspora::Markdownify::Email do
describe '#preprocess' do
before do
@html = Diaspora::Markdownify::Email.new
end
it 'should autolink a hashtag' do
markdownified = @html.preprocess("#tag")
expect(markdownified).to eq("[#tag](http://localhost:9887/tags/tag)")
end
it 'should autolink multiple hashtags' do
markdownified = @html.preprocess("oh #l #loL")
expect(markdownified).to eq("oh [#l](http://localhost:9887/tags/l) [#loL](http://localhost:9887/tags/lol)")
end
it 'should not autolink headers' do
markdownified = @html.preprocess("# header")
expect(markdownified).to eq("# header")
end
end
describe "Markdown rendering" do
before do
@markdown = Redcarpet::Markdown.new(Diaspora::Markdownify::Email)
@sample_text = "# Header\n\n#messages containing #hashtags should render properly"
end
it 'should render the message' do
rendered = @markdown.render(@sample_text).strip
expect(rendered).to eq("<h1>Header</h1>\n\n<p><a href=\"http://localhost:9887/tags/messages\">#messages</a> containing <a href=\"http://localhost:9887/tags/hashtags\">#hashtags</a> should render properly</p>")
end
end
end