From 2cd84ad74515f823ba98cf59eb9f5fc474867b8d Mon Sep 17 00:00:00 2001 From: Abhay Nikam Date: Mon, 16 Dec 2019 13:48:19 +0530 Subject: [PATCH] Fixed typo in the class_names helper documentation and added a spec covering the scenario --- actionview/lib/action_view/helpers/tag_helper.rb | 2 +- actionview/test/template/tag_helper_test.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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