Merge pull request #1149 from charliequinn/allow-nil-value-in-markdown-1145
Bug fix nil parameter ApplicationHelper.markdown
This commit is contained in:
commit
3e2b2f3678
2 changed files with 18 additions and 0 deletions
|
|
@ -254,6 +254,8 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def markdown(text)
|
def markdown(text)
|
||||||
|
return '' if text.nil?
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
autolink: true,
|
autolink: true,
|
||||||
space_after_headers: true,
|
space_after_headers: true,
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,22 @@ describe ApplicationHelper, type: :helper do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'markdown' do
|
||||||
|
it 'should return empty string for nil' do
|
||||||
|
expect(markdown(nil)).to eq ''
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should return HTML for header markdown' do
|
||||||
|
expect(Redcarpet::Markdown).to receive(:new).
|
||||||
|
with(Redcarpet::Render::HTML, autolink: true,
|
||||||
|
space_after_headers: true,
|
||||||
|
no_intra_emphasis: true).
|
||||||
|
and_call_original
|
||||||
|
|
||||||
|
expect(markdown('# this is my header')).to eq "<h1>this is my header</h1>\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#registered_text' do
|
describe '#registered_text' do
|
||||||
describe 'returns correct string' do
|
describe 'returns correct string' do
|
||||||
it 'when there are no registrations' do
|
it 'when there are no registrations' do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue