Skip to content

Commit 4a5094e

Browse files
committed
Fix arity of SafeBuffer#as_json
1 parent fc19243 commit 4a5094e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

activesupport/test/core_ext/string_ext_test.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
require "active_support/inflector"
1010
require "active_support/core_ext/string"
11+
require "active_support/core_ext/object/json"
1112
require "active_support/time"
1213
require "active_support/core_ext/string/output_safety"
1314
require "active_support/core_ext/string/indent"
@@ -1085,6 +1086,16 @@ def to_s
10851086
assert_not_predicate string.to_param, :html_safe?
10861087
end
10871088

1089+
test "as_json returns a normal string" do
1090+
string = @string.html_safe
1091+
assert_not_predicate string.as_json, :html_safe?
1092+
end
1093+
1094+
test "as_json accepts options" do
1095+
hash = { string: @string.html_safe }
1096+
assert_not_predicate hash.as_json(only: :string).fetch("string"), :html_safe?
1097+
end
1098+
10881099
test "ERB::Util.html_escape should escape unsafe characters" do
10891100
string = '<>&"\''
10901101
expected = "&lt;&gt;&amp;&quot;&#39;"

0 commit comments

Comments
 (0)