aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-10-30 14:19:34 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-10-30 14:19:34 -0700
commite83989b5a79c264966ce07e5f4a1e160399505f6 (patch)
tree8d63b6b65628271bfb3acafb7f0847bf60c79e70 /activesupport/test
parent1d75efed8400cb28a7c56e6625be7df31e926c5a (diff)
parent8c36eade647357de0acfa1371c4c2e28334ed81d (diff)
downloadrails-e83989b5a79c264966ce07e5f4a1e160399505f6.tar.gz
rails-e83989b5a79c264966ce07e5f4a1e160399505f6.tar.bz2
rails-e83989b5a79c264966ce07e5f4a1e160399505f6.zip
Merge branch 'master' of github.com:rails/rails
* 'master' of github.com:rails/rails: Fix release instructions Raise an error when AS::JSON.decode is called with options Moved all JSON core extensions into core_ext/object/json
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/object/json_test.rb9
-rw-r--r--activesupport/test/json/decoding_test.rb6
-rw-r--r--activesupport/test/json/encoding_test.rb8
-rw-r--r--activesupport/test/ordered_hash_test.rb2
4 files changed, 20 insertions, 5 deletions
diff --git a/activesupport/test/core_ext/object/json_test.rb b/activesupport/test/core_ext/object/json_test.rb
new file mode 100644
index 0000000000..d3d31530df
--- /dev/null
+++ b/activesupport/test/core_ext/object/json_test.rb
@@ -0,0 +1,9 @@
+require 'abstract_unit'
+
+class JsonTest < ActiveSupport::TestCase
+ # See activesupport/test/json/encoding_test.rb for JSON encoding tests
+
+ def test_deprecated_require_to_json_rb
+ assert_deprecated { require 'active_support/core_ext/object/to_json' }
+ end
+end
diff --git a/activesupport/test/json/decoding_test.rb b/activesupport/test/json/decoding_test.rb
index e9780b36e4..07d7e530ca 100644
--- a/activesupport/test/json/decoding_test.rb
+++ b/activesupport/test/json/decoding_test.rb
@@ -98,10 +98,8 @@ class TestJSONDecoding < ActiveSupport::TestCase
assert_raise(ActiveSupport::JSON.parse_error) { ActiveSupport::JSON.decode(%()) }
end
- def test_cannot_force_json_unmarshalling
- encodeded = %q({"json_class":"TestJSONDecoding::Foo"})
- decodeded = {"json_class"=>"TestJSONDecoding::Foo"}
- assert_equal decodeded, ActiveSupport::JSON.decode(encodeded, create_additions: true)
+ def test_cannot_pass_unsupported_options
+ assert_raise(ArgumentError) { ActiveSupport::JSON.decode("", create_additions: true) }
end
end
diff --git a/activesupport/test/json/encoding_test.rb b/activesupport/test/json/encoding_test.rb
index ed1326705c..d549113ff4 100644
--- a/activesupport/test/json/encoding_test.rb
+++ b/activesupport/test/json/encoding_test.rb
@@ -1,4 +1,5 @@
# encoding: utf-8
+require 'securerandom'
require 'abstract_unit'
require 'active_support/core_ext/string/inflections'
require 'active_support/json'
@@ -96,6 +97,13 @@ class TestJSONEncoding < ActiveSupport::TestCase
end
end
+ def test_process_status
+ # There doesn't seem to be a good way to get a handle on a Process::Status object without actually
+ # creating a child process, hence this to populate $?
+ system("not_a_real_program_#{SecureRandom.hex}")
+ assert_equal %({"exitstatus":#{$?.exitstatus},"pid":#{$?.pid}}), ActiveSupport::JSON.encode($?)
+ end
+
def test_hash_encoding
assert_equal %({\"a\":\"b\"}), ActiveSupport::JSON.encode(:a => :b)
assert_equal %({\"a\":1}), ActiveSupport::JSON.encode('a' => 1)
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'