File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed
lib/active_support/core_ext/object Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 1+ * Fix behavior of JSON encoding for ` Exception ` .
2+
3+ * namusyaka*
4+
15* Make ` number_to_phone ` format number with regexp pattern.
26
37 number_to_phone(18812345678, pattern: /(\d{3})(\d{4})(\d{4})/)
Original file line number Diff line number Diff line change @@ -197,3 +197,9 @@ def as_json(options = nil)
197197 { :exitstatus => exitstatus , :pid => pid }
198198 end
199199end
200+
201+ class Exception
202+ def as_json ( options = nil )
203+ to_s
204+ end
205+ end
Original file line number Diff line number Diff line change @@ -422,6 +422,11 @@ def test_twz_to_json_when_wrapping_a_date_time
422422 assert_equal '"1999-12-31T19:00:00.000-05:00"' , ActiveSupport ::JSON . encode ( time )
423423 end
424424
425+ def test_exception_to_json
426+ exception = Exception . new ( "foo" )
427+ assert_equal '"foo"' , ActiveSupport ::JSON . encode ( exception )
428+ end
429+
425430 protected
426431
427432 def object_keys ( json_object )
You can’t perform that action at this time.
0 commit comments