File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
activesupport/test/core_ext Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 8
8
9
9
require "active_support/inflector"
10
10
require "active_support/core_ext/string"
11
+ require "active_support/core_ext/object/json"
11
12
require "active_support/time"
12
13
require "active_support/core_ext/string/output_safety"
13
14
require "active_support/core_ext/string/indent"
@@ -1085,6 +1086,16 @@ def to_s
1085
1086
assert_not_predicate string . to_param , :html_safe?
1086
1087
end
1087
1088
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
+
1088
1099
test "ERB::Util.html_escape should escape unsafe characters" do
1089
1100
string = '<>&"\''
1090
1101
expected = "<>&"'"
You can’t perform that action at this time.
0 commit comments