aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorMike Subelsky <github@mikeshop.net>2008-07-02 14:15:43 -0400
committerrick <technoweenie@gmail.com>2008-07-02 11:39:42 -0700
commit8f640c381d9d1b74f6a0fc3648c21da373661914 (patch)
treed179b1200ce573847076301646fac854e66b11ab /actionpack/test
parenta4138d46321d63012adbf1942f5ea7c5e4951fc9 (diff)
downloadrails-8f640c381d9d1b74f6a0fc3648c21da373661914.tar.gz
rails-8f640c381d9d1b74f6a0fc3648c21da373661914.tar.bz2
rails-8f640c381d9d1b74f6a0fc3648c21da373661914.zip
Added application/jsonrequest as a synonym for application/json
[#536 state:resolved]
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/request_test.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/actionpack/test/controller/request_test.rb b/actionpack/test/controller/request_test.rb
index 2bd489b2c7..20f3fd4d7b 100644
--- a/actionpack/test/controller/request_test.rb
+++ b/actionpack/test/controller/request_test.rb
@@ -909,15 +909,21 @@ class LegacyXmlParamsParsingTest < XmlParamsParsingTest
end
class JsonParamsParsingTest < Test::Unit::TestCase
- def test_hash_params
- person = parse_body({:person => {:name => "David"}}.to_json)[:person]
+ def test_hash_params_for_application_json
+ person = parse_body({:person => {:name => "David"}}.to_json,'application/json')[:person]
+ assert_kind_of Hash, person
+ assert_equal 'David', person['name']
+ end
+
+ def test_hash_params_for_application_jsonrequest
+ person = parse_body({:person => {:name => "David"}}.to_json,'application/jsonrequest')[:person]
assert_kind_of Hash, person
assert_equal 'David', person['name']
end
private
- def parse_body(body)
- env = { 'CONTENT_TYPE' => 'application/json',
+ def parse_body(body,content_type)
+ env = { 'CONTENT_TYPE' => content_type,
'CONTENT_LENGTH' => body.size.to_s }
cgi = ActionController::Integration::Session::StubCGI.new(env, body)
ActionController::CgiRequest.new(cgi).request_parameters