Upgrade to Rails 2.2.0
As a side benefit, fix an (non-user-visible) bug in display_s5(). Also fixed a bug where removing orphaned pages did not expire cached summary pages.
This commit is contained in:
parent
39348c65c2
commit
7600aef48b
827 changed files with 123652 additions and 11027 deletions
|
@ -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.
|
||||
|
@ -243,10 +243,171 @@ class IntegrationTestUsesCorrectClass < ActionController::IntegrationTest
|
|||
reset!
|
||||
stub_integration_session(@integration_session)
|
||||
%w( get post head put delete ).each do |verb|
|
||||
assert_nothing_raised("'#{verb}' should use integration test methods") { send!(verb, '/') }
|
||||
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
|
||||
respond_to do |format|
|
||||
format.html { render :text => "OK", :status => 200 }
|
||||
format.js { render :text => "JS OK", :status => 200 }
|
||||
end
|
||||
end
|
||||
|
||||
def get_with_params
|
||||
render :text => "foo: #{params[:foo]}", :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
|
||||
|
||||
def redirect
|
||||
redirect_to :action => "get"
|
||||
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_response 200
|
||||
assert_response :success
|
||||
assert_response :ok
|
||||
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_response 201
|
||||
assert_response :success
|
||||
assert_response :created
|
||||
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_response 410
|
||||
assert_response :gone
|
||||
assert_equal ["cookie_1=; path=/", "cookie_3=chocolate; path=/"], response.headers["Set-Cookie"]
|
||||
assert_equal ["cookie_1=; path=/", "cookie_3=chocolate; path=/"], headers['set-cookie']
|
||||
assert_equal [
|
||||
CGI::Cookie::new("name" => "cookie_1", "value" => ""),
|
||||
CGI::Cookie::new("name" => "cookie_3", "value" => "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
|
||||
|
||||
def test_redirect
|
||||
with_test_route_set do
|
||||
get '/redirect'
|
||||
assert_equal 302, status
|
||||
assert_equal "Found", status_message
|
||||
assert_equal "302 Found", response.headers["Status"]
|
||||
assert_equal ["302 Found"], headers["status"]
|
||||
assert_response 302
|
||||
assert_response :redirect
|
||||
assert_response :found
|
||||
assert_equal "<html><body>You are being <a href=\"http://www.example.com/get\">redirected</a>.</body></html>", response.body
|
||||
assert_kind_of HTML::Document, html_document
|
||||
assert_equal 1, request_count
|
||||
end
|
||||
end
|
||||
|
||||
def test_xml_http_request_get
|
||||
with_test_route_set do
|
||||
xhr :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_response 200
|
||||
assert_response :success
|
||||
assert_response :ok
|
||||
assert_equal "JS OK", response.body
|
||||
end
|
||||
end
|
||||
|
||||
def test_get_with_query_string
|
||||
with_test_route_set do
|
||||
get '/get_with_params?foo=bar'
|
||||
assert_equal '/get_with_params?foo=bar', request.env["REQUEST_URI"]
|
||||
assert_equal '/get_with_params?foo=bar', request.request_uri
|
||||
assert_equal nil, request.env["QUERY_STRING"]
|
||||
assert_equal 'foo=bar', request.query_string
|
||||
assert_equal 'bar', request.parameters['foo']
|
||||
|
||||
assert_equal 200, status
|
||||
assert_equal "foo: bar", response.body
|
||||
end
|
||||
end
|
||||
|
||||
def test_get_with_parameters
|
||||
with_test_route_set do
|
||||
get '/get_with_params', :foo => "bar"
|
||||
assert_equal '/get_with_params', request.env["REQUEST_URI"]
|
||||
assert_equal '/get_with_params', request.request_uri
|
||||
assert_equal 'foo=bar', request.env["QUERY_STRING"]
|
||||
assert_equal 'foo=bar', request.query_string
|
||||
assert_equal 'bar', request.parameters['foo']
|
||||
|
||||
assert_equal 200, status
|
||||
assert_equal "foo: bar", 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 "/:action"
|
||||
end
|
||||
end
|
||||
yield
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end # uses_mocha
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue