Fixed typo in the class_names helper documentation and added a spec covering the scenario

This commit is contained in:
Abhay Nikam 2019-12-16 13:48:19 +05:30
parent f2b69d80ab
commit 2cd84ad745
2 changed files with 2 additions and 1 deletions

View File

@ -298,7 +298,7 @@ module ActionView
# class_names({ foo: true, bar: false })
# # => "foo"
# class_names(nil, false, 123, "", "foo", { bar: true })
# # => "foo bar"
# # => "123 foo bar"
def class_names(*args)
safe_join(build_tag_values(*args), " ")
end

View File

@ -347,6 +347,7 @@ class TagHelperTest < ActionView::TestCase
assert_equal "song", class_names(["song", { foo: false }])
assert_equal "song play", class_names({ "song": true, "play": true })
assert_equal "", class_names({ "song": false, "play": false })
assert_equal "123", class_names(nil, "", false, 123, { "song": false, "play": false })
end
def test_content_tag_with_data_attributes