aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/ordered_hash_test.rb
diff options
context:
space:
mode:
authorGodfrey Chan <godfreykfc@gmail.com>2013-09-11 18:36:23 -0700
committerGodfrey Chan <godfreykfc@gmail.com>2013-09-13 03:04:10 -0700
commit64c88fb5d2caf3c34742a07394ac68b8377c4936 (patch)
tree33efc6408ac0d8ce203c82a3eb8b216cfd94468c /activesupport/test/ordered_hash_test.rb
parentdefdeed2fc1f6f30c8eeebc7e2695d82624942e2 (diff)
downloadrails-64c88fb5d2caf3c34742a07394ac68b8377c4936.tar.gz
rails-64c88fb5d2caf3c34742a07394ac68b8377c4936.tar.bz2
rails-64c88fb5d2caf3c34742a07394ac68b8377c4936.zip
Moved all JSON core extensions into core_ext/object/json
TL;DR The primary driver is to remove autoload surprise. This is related to #12106. (The root cause for that ticket is that json/add defines Regexp#to_json among others, but here I'll reproduce the problem without json/add.) Before: >> require 'active_support/core_ext/to_json' => true >> //.as_json NoMethodError: undefined method `as_json' for //:Regexp from (irb):3 from /Users/godfrey/.rvm/rubies/ruby-2.0.0-p195/bin/irb:16:in `<main>' >> //.to_json => "\"(?-mix:)\"" >> //.as_json => "(?-mix:)" After: >> require 'active_support/core_ext/to_json' => true >> //.as_json => "(?-mix:)" This is because ActiveSupport::JSON is autoloaded the first time Object#to_json is called, which causes additional core extentions (previously defined in active_support/json/encoding.rb) to be loaded. When someone require 'active_support/core_ext', the expectation is that it would add certain methods to the core classes NOW. The previous behaviour causes additional methods to be loaded the first time you call `to_json`, which could cause nasty surprises and other unplesant side-effects. This change moves all core extensions in to core_ext/json. AS::JSON is still autoloaded on first #to_json call, but since it nolonger include the core extensions, it should address the aforementioned bug. *Requiring core_ext/object/to_json now causes a deprecation warnning*
Diffstat (limited to 'activesupport/test/ordered_hash_test.rb')
-rw-r--r--activesupport/test/ordered_hash_test.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activesupport/test/ordered_hash_test.rb b/activesupport/test/ordered_hash_test.rb
index c3fe89de4b..0b54026c64 100644
--- a/activesupport/test/ordered_hash_test.rb
+++ b/activesupport/test/ordered_hash_test.rb
@@ -1,6 +1,6 @@
require 'abstract_unit'
require 'active_support/json'
-require 'active_support/core_ext/object/to_json'
+require 'active_support/core_ext/object/json'
require 'active_support/core_ext/hash/indifferent_access'
require 'active_support/core_ext/array/extract_options'