aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
authorkenta-s <knt01222@gmail.com>2017-01-15 21:10:05 +0900
committerkenta-s <knt01222@gmail.com>2017-01-15 21:10:05 +0900
commit8040f527c3f75638829809662a52af04d50369f9 (patch)
tree41123f3b4509110b2af6e1d28197f6be217fdd42 /actionview
parentb1a417011478e50475240620318f38d6829c1ad8 (diff)
downloadrails-8040f527c3f75638829809662a52af04d50369f9.tar.gz
rails-8040f527c3f75638829809662a52af04d50369f9.tar.bz2
rails-8040f527c3f75638829809662a52af04d50369f9.zip
Fix unexpected behavior of with $,
Diffstat (limited to 'actionview')
-rw-r--r--actionview/lib/action_view/helpers/output_safety_helper.rb2
-rw-r--r--actionview/test/template/output_safety_helper_test.rb10
2 files changed, 11 insertions, 1 deletions
diff --git a/actionview/lib/action_view/helpers/output_safety_helper.rb b/actionview/lib/action_view/helpers/output_safety_helper.rb
index e9febb8be9..25defd1276 100644
--- a/actionview/lib/action_view/helpers/output_safety_helper.rb
+++ b/actionview/lib/action_view/helpers/output_safety_helper.rb
@@ -60,7 +60,7 @@ module ActionView #:nodoc:
when 2
safe_join([array[0], array[1]], options[:two_words_connector])
else
- safe_join([safe_join(array[0...-1], options[:words_connector]), options[:last_word_connector], array[-1]])
+ safe_join([safe_join(array[0...-1], options[:words_connector]), options[:last_word_connector], array[-1]], nil)
end
end
end
diff --git a/actionview/test/template/output_safety_helper_test.rb b/actionview/test/template/output_safety_helper_test.rb
index 8691bb11ee..41ae36e91a 100644
--- a/actionview/test/template/output_safety_helper_test.rb
+++ b/actionview/test/template/output_safety_helper_test.rb
@@ -87,4 +87,14 @@ class OutputSafetyHelperTest < ActionView::TestCase
assert_equal "one, two three", to_sentence(["one", "two", "three"], last_word_connector: " ")
assert_equal "one, two and three", to_sentence(["one", "two", "three"], last_word_connector: " and ")
end
+
+ test "to_sentence is not affected by $," do
+ $, = "|"
+ begin
+ assert_equal "one and two", to_sentence(["one", "two"])
+ assert_equal "one, two, and three", to_sentence(["one", "two", "three"])
+ ensure
+ $, = nil
+ end
+ end
end