aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template/output_safety_helper_test.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-08-06 18:50:17 +0200
committerXavier Noria <fxn@hashref.com>2016-08-06 18:50:17 +0200
commit4b6c68dfb810c836f87587a16353317d1a180805 (patch)
treebebdbb90baa5f07de0688ec255ee18b460053d18 /actionview/test/template/output_safety_helper_test.rb
parent66a7cfa91045e05f134efc9ac0e226e66161e2e6 (diff)
downloadrails-4b6c68dfb810c836f87587a16353317d1a180805.tar.gz
rails-4b6c68dfb810c836f87587a16353317d1a180805.tar.bz2
rails-4b6c68dfb810c836f87587a16353317d1a180805.zip
applies new string literal convention in actionview/test
The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
Diffstat (limited to 'actionview/test/template/output_safety_helper_test.rb')
-rw-r--r--actionview/test/template/output_safety_helper_test.rb34
1 files changed, 17 insertions, 17 deletions
diff --git a/actionview/test/template/output_safety_helper_test.rb b/actionview/test/template/output_safety_helper_test.rb
index b940c9dd36..98b1938276 100644
--- a/actionview/test/template/output_safety_helper_test.rb
+++ b/actionview/test/template/output_safety_helper_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit'
+require "abstract_unit"
class OutputSafetyHelperTest < ActionView::TestCase
tests ActionView::Helpers::OutputSafetyHelper
@@ -26,11 +26,11 @@ class OutputSafetyHelperTest < ActionView::TestCase
end
test "safe_join should work recursively similarly to Array.join" do
- joined = safe_join(['a',['b','c']], ':')
- assert_equal 'a:b:c', joined
+ joined = safe_join(["a",["b","c"]], ":")
+ assert_equal "a:b:c", joined
- joined = safe_join(['"a"',['<b>','<c>']], ' <br/> ')
- assert_equal '&quot;a&quot; &lt;br/&gt; &lt;b&gt; &lt;br/&gt; &lt;c&gt;', joined
+ joined = safe_join(['"a"',["<b>","<c>"]], " <br/> ")
+ assert_equal "&quot;a&quot; &lt;br/&gt; &lt;b&gt; &lt;br/&gt; &lt;c&gt;", joined
end
test "to_sentence should escape non-html_safe values" do
@@ -50,9 +50,9 @@ class OutputSafetyHelperTest < ActionView::TestCase
end
test "to_sentence connector words are checked for html safety" do
- assert_equal "one & two, and three", to_sentence(['one', 'two', 'three'], words_connector: ' & '.html_safe)
- assert_equal "one & two", to_sentence(['one', 'two'], two_words_connector: ' & '.html_safe)
- assert_equal "one, two &lt;script&gt;alert(1)&lt;/script&gt; three", to_sentence(['one', 'two', 'three'], last_word_connector: ' <script>alert(1)</script> ')
+ assert_equal "one & two, and three", to_sentence(["one", "two", "three"], words_connector: " & ".html_safe)
+ assert_equal "one & two", to_sentence(["one", "two"], two_words_connector: " & ".html_safe)
+ assert_equal "one, two &lt;script&gt;alert(1)&lt;/script&gt; three", to_sentence(["one", "two", "three"], last_word_connector: " <script>alert(1)</script> ")
end
test "to_sentence should not escape html_safe values" do
@@ -67,24 +67,24 @@ class OutputSafetyHelperTest < ActionView::TestCase
end
test "to_sentence handles blank strings" do
- actual = to_sentence(['', 'two', 'three'])
+ actual = to_sentence(["", "two", "three"])
assert actual.html_safe?
assert_equal ", two, and three", actual
end
test "to_sentence handles nil values" do
- actual = to_sentence([nil, 'two', 'three'])
+ actual = to_sentence([nil, "two", "three"])
assert actual.html_safe?
assert_equal ", two, and three", actual
end
test "to_sentence still supports ActiveSupports Array#to_sentence arguments" do
- assert_equal "one two, and three", to_sentence(['one', 'two', 'three'], words_connector: ' ')
- assert_equal "one & two, and three", to_sentence(['one', 'two', 'three'], words_connector: ' & '.html_safe)
- assert_equal "onetwo, and three", to_sentence(['one', 'two', 'three'], words_connector: nil)
- assert_equal "one, two, and also three", to_sentence(['one', 'two', 'three'], last_word_connector: ', and also ')
- assert_equal "one, twothree", to_sentence(['one', 'two', 'three'], last_word_connector: nil)
- 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 ')
+ assert_equal "one two, and three", to_sentence(["one", "two", "three"], words_connector: " ")
+ assert_equal "one & two, and three", to_sentence(["one", "two", "three"], words_connector: " & ".html_safe)
+ assert_equal "onetwo, and three", to_sentence(["one", "two", "three"], words_connector: nil)
+ assert_equal "one, two, and also three", to_sentence(["one", "two", "three"], last_word_connector: ", and also ")
+ assert_equal "one, twothree", to_sentence(["one", "two", "three"], last_word_connector: nil)
+ 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
end