1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Test to check if the data-attr if nil is same or not

if data attribute is nil it is ignored

if value is nil the pair is ignored

if value is nil it is skipped

Improved test for  data attr nil
This commit is contained in:
Sourav Moitra 2016-02-13 03:36:59 +05:30
parent 73fb2977ca
commit aeee438bf1
2 changed files with 7 additions and 0 deletions

View file

@ -154,6 +154,7 @@ module ActionView
options.each_pair do |key, value| options.each_pair do |key, value|
if TAG_PREFIXES.include?(key) && value.is_a?(Hash) if TAG_PREFIXES.include?(key) && value.is_a?(Hash)
value.each_pair do |k, v| value.each_pair do |k, v|
next if v.nil?
output << sep output << sep
output << prefix_tag_option(key, k, v, escape) output << prefix_tag_option(key, k, v, escape)
end end

View file

@ -173,4 +173,10 @@ class TagHelperTest < ActionView::TestCase
tag('a', { aria => { 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"' } }) tag('a', { aria => { 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
def test_link_to_data_nil_equal
div_type1 = content_tag(:div, 'test', { 'data-tooltip' => nil })
div_type2 = content_tag(:div, 'test', { data: {tooltip: nil} })
assert_dom_equal div_type1, div_type2
end
end end