aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_controller/test_process.rb10
-rw-r--r--actionpack/test/controller/test_test.rb17
3 files changed, 29 insertions, 0 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 96eb8ac77d..3b63e4b44c 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Added TestRequest#raw_post that simulate raw_post from CgiRequest #3042 [francois.beausoleil@gmail.com]
+
* Underscore dasherized keys in formatted requests [Jamis Buck]
* Add MimeResponds::Responder#any for managing multiple types with identical responses [Jamis Buck]
diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb
index 7dfc16785a..85bcc7372d 100644
--- a/actionpack/lib/action_controller/test_process.rb
+++ b/actionpack/lib/action_controller/test_process.rb
@@ -41,7 +41,17 @@ module ActionController #:nodoc:
def reset_session
@session = {}
end
+
+ def raw_post
+ params = self.request_parameters.dup
+ %w(controller action only_path).each do |k|
+ params.delete(k)
+ params.delete(k.to_sym)
+ end
+ params.map { |k,v| [ CGI.escape(k.to_s), CGI.escape(v.to_s) ].join('=') }.sort.join('&')
+ end
+
def port=(number)
@env["SERVER_PORT"] = number.to_i
@port_as_int = nil
diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb
index dcb16841ae..25c514d5a3 100644
--- a/actionpack/test/controller/test_test.rb
+++ b/actionpack/test/controller/test_test.rb
@@ -8,6 +8,11 @@ class TestTest < Test::Unit::TestCase
render :text => 'ignore me'
end
+ def render_raw_post
+ raise Test::Unit::AssertionFailedError, "#raw_post is blank" if request.raw_post.blank?
+ render :text => request.raw_post
+ end
+
def test_params
render :text => params.inspect
end
@@ -44,6 +49,10 @@ HTML
def test_remote_addr
render :text => (request.remote_addr || "not specified")
end
+
+ def rescue_action(e)
+ raise e
+ end
end
def setup
@@ -57,6 +66,14 @@ HTML
ActionController::Routing::Routes.reload
end
+ def test_raw_post_handling
+ params = {:page => {:name => 'page name'}, 'some key' => 123}
+ get :render_raw_post, params.dup
+
+ raw_post = params.map {|k,v| [CGI::escape(k.to_s), CGI::escape(v.to_s)].join('=')}.sort.join('&')
+ assert_equal raw_post, @response.body
+ end
+
def test_process_without_flash
process :set_flash
assert_equal '><', flash['test']