Skip to content

Commit

Permalink
Add test cases for introduce this bug
Browse files Browse the repository at this point in the history
  • Loading branch information
davydovanton committed Jan 25, 2016
1 parent 70d064e commit 814e8b3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/fixtures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -569,3 +569,22 @@ def link_to_with_content_html_content_id_and_class
end

end

class HtmlAndLinkTo
include Hanami::Helpers::HtmlHelper
include Hanami::Helpers::LinkToHelper

def two_links_to_in_div
html.div do
link_to('Posts', 'posts')
link_to('Comments', 'comments')
end
end

def span_and_link_to_in_div
html.div do
span 'hello'
link_to('Comments', 'comments')
end
end
end
14 changes: 14 additions & 0 deletions test/html_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,18 @@
it 'autoescapes nested blocks' do
@view.evil_nested_block_content.to_s.must_equal %(<div>\n<p>&lt;script&gt;alert(&apos;xss&apos;)&lt;&#x2F;script&gt;</p>\n</div>)
end

describe 'with link_to helper' do
before do
@view = HtmlAndLinkTo.new
end

it 'returns two links in div' do
@view.two_links_to_in_div.to_s.must_equal %(<div>\n<a href=\"comments\">Comments</a>\n<a href=\"posts\">Posts</a>\n</div>)
end

it 'returns span and link in div' do
@view.span_and_link_to_in_div.to_s.must_equal %(<div>\n<span>hello</span>\n<a href=\"posts\">Posts</a>\n</div>)
end
end
end

0 comments on commit 814e8b3

Please sign in to comment.