aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/tag_helper_test.rb
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-11-01 08:49:47 -0200
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-11-01 08:49:47 -0200
commitb31ea0c240773c557a6c4e1a0e470a9d442406ee (patch)
treeb049681a9402a01651984de58dbde421d193f894 /actionpack/test/template/tag_helper_test.rb
parentc7e233ce47c050e086aa9eae7b0217c3d9e405dd (diff)
downloadrails-b31ea0c240773c557a6c4e1a0e470a9d442406ee.tar.gz
rails-b31ea0c240773c557a6c4e1a0e470a9d442406ee.tar.bz2
rails-b31ea0c240773c557a6c4e1a0e470a9d442406ee.zip
Add test to ensure data attributes are properly escaped with tag helpers
Closes #8091
Diffstat (limited to 'actionpack/test/template/tag_helper_test.rb')
-rw-r--r--actionpack/test/template/tag_helper_test.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/actionpack/test/template/tag_helper_test.rb b/actionpack/test/template/tag_helper_test.rb
index f0a7ce0bc9..9e711c6529 100644
--- a/actionpack/test/template/tag_helper_test.rb
+++ b/actionpack/test/template/tag_helper_test.rb
@@ -87,6 +87,11 @@ class TagHelperTest < ActionView::TestCase
assert_equal "<p class=\"song play>\">limelight</p>", str
end
+ def test_content_tag_with_data_attributes
+ assert_dom_equal '<p data-number="1" data-string="hello" data-string-with-quotes="double&quot;quote&quot;party&quot;">limelight</p>',
+ content_tag('p', "limelight", data: { number: 1, string: 'hello', string_with_quotes: 'double"quote"party"' })
+ end
+
def test_cdata_section
assert_equal "<![CDATA[<hello world>]]>", cdata_section("<hello world>")
end
@@ -118,8 +123,8 @@ class TagHelperTest < ActionView::TestCase
def test_data_attributes
['data', :data].each { |data|
- assert_dom_equal '<a data-a-float="3.14" data-a-big-decimal="-123.456" data-a-number="1" data-array="[1,2,3]" data-hash="{&quot;key&quot;:&quot;value&quot;}" data-string="hello" data-symbol="foo" />',
- tag('a', { data => { :a_float => 3.14, :a_big_decimal => BigDecimal.new("-123.456"), :a_number => 1, :string => 'hello', :symbol => :foo, :array => [1, 2, 3], :hash => { :key => 'value'} } })
+ assert_dom_equal '<a data-a-float="3.14" data-a-big-decimal="-123.456" data-a-number="1" data-array="[1,2,3]" data-hash="{&quot;key&quot;:&quot;value&quot;}" data-string-with-quotes="double&quot;quote&quot;party&quot;" data-string="hello" data-symbol="foo" />',
+ tag('a', { data => { a_float: 3.14, a_big_decimal: BigDecimal.new("-123.456"), a_number: 1, string: 'hello', symbol: :foo, array: [1, 2, 3], hash: { key: 'value'}, string_with_quotes: 'double"quote"party"' } })
}
end
end