aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/CHANGELOG.md4
-rw-r--r--activesupport/lib/active_support/json/encoding.rb22
-rw-r--r--activesupport/test/json/encoding_test.rb24
3 files changed, 4 insertions, 46 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index 017a306c1b..be9c8a04b7 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -1,3 +1,7 @@
+* Remove deprecated `ActiveSupport::JSON::Encoding::CircularReferenceError`.
+
+ *Rafael Mendonça França*
+
* Remove deprecated methods `ActiveSupport::JSON::Encoding.encode_big_decimal_as_string=`
and `ActiveSupport::JSON::Encoding.encode_big_decimal_as_string`.
diff --git a/activesupport/lib/active_support/json/encoding.rb b/activesupport/lib/active_support/json/encoding.rb
index 20833eff90..48f4967892 100644
--- a/activesupport/lib/active_support/json/encoding.rb
+++ b/activesupport/lib/active_support/json/encoding.rb
@@ -112,28 +112,6 @@ module ActiveSupport
# Sets the encoder used by Rails to encode Ruby objects into JSON strings
# in +Object#to_json+ and +ActiveSupport::JSON.encode+.
attr_accessor :json_encoder
-
- # Deprecate CircularReferenceError
- def const_missing(name)
- if name == :CircularReferenceError
- message = "The JSON encoder in Rails 4.1 no longer offers protection from circular references. " \
- "You are seeing this warning because you are rescuing from (or otherwise referencing) " \
- "ActiveSupport::Encoding::CircularReferenceError. In the future, this error will be " \
- "removed from Rails. You should remove these rescue blocks from your code and ensure " \
- "that your data structures are free of circular references so they can be properly " \
- "serialized into JSON.\n\n" \
- "For example, the following Hash contains a circular reference to itself:\n" \
- " h = {}\n" \
- " h['circular'] = h\n" \
- "In this case, calling h.to_json would not work properly."
-
- ActiveSupport::Deprecation.warn message
-
- SystemStackError
- else
- super
- end
- end
end
self.use_standard_json_time_format = true
diff --git a/activesupport/test/json/encoding_test.rb b/activesupport/test/json/encoding_test.rb
index 48f634a78b..5c5045da1e 100644
--- a/activesupport/test/json/encoding_test.rb
+++ b/activesupport/test/json/encoding_test.rb
@@ -176,30 +176,6 @@ class TestJSONEncoding < ActiveSupport::TestCase
assert_equal "𐒑", decoded_hash['string']
end
- def test_exception_raised_when_encoding_circular_reference_in_array
- a = [1]
- a << a
- assert_deprecated do
- assert_raise(ActiveSupport::JSON::Encoding::CircularReferenceError) { ActiveSupport::JSON.encode(a) }
- end
- end
-
- def test_exception_raised_when_encoding_circular_reference_in_hash
- a = { :name => 'foo' }
- a[:next] = a
- assert_deprecated do
- assert_raise(ActiveSupport::JSON::Encoding::CircularReferenceError) { ActiveSupport::JSON.encode(a) }
- end
- end
-
- def test_exception_raised_when_encoding_circular_reference_in_hash_inside_array
- a = { :name => 'foo', :sub => [] }
- a[:sub] << a
- assert_deprecated do
- assert_raise(ActiveSupport::JSON::Encoding::CircularReferenceError) { ActiveSupport::JSON.encode(a) }
- end
- end
-
def test_hash_key_identifiers_are_always_quoted
values = {0 => 0, 1 => 1, :_ => :_, "$" => "$", "a" => "a", :A => :A, :A0 => :A0, "A0B" => "A0B"}
assert_equal %w( "$" "A" "A0" "A0B" "_" "a" "0" "1" ).sort, object_keys(ActiveSupport::JSON.encode(values))