diff --git a/actionview/lib/action_view/helpers/tag_helper.rb b/actionview/lib/action_view/helpers/tag_helper.rb index b7f8661f2e..ad0df7fafb 100644 --- a/actionview/lib/action_view/helpers/tag_helper.rb +++ b/actionview/lib/action_view/helpers/tag_helper.rb @@ -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 diff --git a/actionview/test/template/tag_helper_test.rb b/actionview/test/template/tag_helper_test.rb index 2c800ff96c..078986ca79 100644 --- a/actionview/test/template/tag_helper_test.rb +++ b/actionview/test/template/tag_helper_test.rb @@ -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