aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/test/controller/integration_test.rb93
1 files changed, 88 insertions, 5 deletions
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb
index 62c00c5b9a..475e13897b 100644
--- a/actionpack/test/controller/integration_test.rb
+++ b/actionpack/test/controller/integration_test.rb
@@ -1,5 +1,6 @@
require 'abstract_unit'
require 'action_controller/integration'
+require 'action_controller/routing'
uses_mocha 'integration' do
@@ -12,12 +13,12 @@ end
class SessionTest < Test::Unit::TestCase
include IntegrationSessionStubbing
-
+
def setup
@session = ActionController::Integration::Session.new
stub_integration_session(@session)
end
-
+
def test_https_bang_works_and_sets_truth_by_default
assert !@session.https?
@session.https!
@@ -196,7 +197,7 @@ class SessionTest < Test::Unit::TestCase
@session.expects(:process).with(:head,path,params,headers_after_xhr)
@session.xml_http_request(:head,path,params,headers)
end
-
+
def test_xml_http_request_override_accept
path = "/index"; params = "blah"; headers = {:location => 'blah', "Accept" => "application/xml"}
headers_after_xhr = headers.merge(
@@ -227,7 +228,6 @@ class IntegrationTestTest < Test::Unit::TestCase
assert_equal ::ActionController::Integration::Session, session2.class
assert_not_equal session1, session2
end
-
end
# Tests that integration tests don't call Controller test methods for processing.
@@ -246,7 +246,90 @@ class IntegrationTestUsesCorrectClass < ActionController::IntegrationTest
assert_nothing_raised("'#{verb}' should use integration test methods") { send!(verb, '/') }
end
end
+end
+
+class IntegrationProcessTest < ActionController::IntegrationTest
+ class IntegrationController < ActionController::Base
+ session :off
+
+ def get
+ render :text => "OK", :status => 200
+ end
+
+ def post
+ render :text => "Created", :status => 201
+ end
+
+ def cookie_monster
+ cookies["cookie_1"] = nil
+ cookies["cookie_3"] = "chocolate"
+ render :text => "Gone", :status => 410
+ end
+ end
+ def test_get
+ with_test_route_set do
+ get '/get'
+ assert_equal 200, status
+ assert_equal "OK", status_message
+ assert_equal "200 OK", response.headers["Status"]
+ assert_equal ["200 OK"], headers["status"]
+ assert_equal [], response.headers["cookie"]
+ assert_equal [], headers["cookie"]
+ assert_equal({}, cookies)
+ assert_equal "OK", response.body
+ assert_kind_of HTML::Document, html_document
+ assert_equal 1, request_count
+ end
+ end
+
+ def test_post
+ with_test_route_set do
+ post '/post'
+ assert_equal 201, status
+ assert_equal "Created", status_message
+ assert_equal "201 Created", response.headers["Status"]
+ assert_equal ["201 Created"], headers["status"]
+ assert_equal [], response.headers["cookie"]
+ assert_equal [], headers["cookie"]
+ assert_equal({}, cookies)
+ assert_equal "Created", response.body
+ assert_kind_of HTML::Document, html_document
+ assert_equal 1, request_count
+ end
+ end
+
+ def test_cookie_monster
+ with_test_route_set do
+ self.cookies['cookie_1'] = "sugar"
+ self.cookies['cookie_2'] = "oatmeal"
+ get '/cookie_monster'
+ assert_equal 410, status
+ assert_equal "Gone", status_message
+ assert_equal "410 Gone", response.headers["Status"]
+ assert_equal ["410 Gone"], headers["status"]
+ assert_equal nil, response.headers["Set-Cookie"]
+ assert_equal ["cookie_1=; path=/", "cookie_3=chocolate; path=/"], headers['set-cookie']
+ assert_equal [[], ["chocolate"]], response.headers["cookie"]
+ assert_equal [], headers["cookie"]
+ assert_equal({"cookie_1"=>"", "cookie_2"=>"oatmeal", "cookie_3"=>"chocolate"}, cookies)
+ assert_equal "Gone", response.body
+ end
+ end
+
+ private
+ def with_test_route_set
+ with_routing do |set|
+ set.draw do |map|
+ map.with_options :controller => "IntegrationProcessTest::Integration" do |c|
+ c.connect '/get', :action => "get"
+ c.connect '/post', :action => "post"
+ c.connect '/cookie_monster', :action => "cookie_monster"
+ end
+ end
+ yield
+ end
+ end
end
-end # uses_mocha
+end