New Version
Sync with Latest Instiki Trunk. Migrate to Rails 1.2.5. Bump version number.
This commit is contained in:
parent
de125367b0
commit
207fb1f7f2
120 changed files with 2592 additions and 662 deletions
|
@ -11,7 +11,7 @@ require 'stubba'
|
|||
module ActionController
|
||||
module Integration
|
||||
class Session
|
||||
def process
|
||||
def process(*args)
|
||||
end
|
||||
|
||||
def generic_url_rewriter
|
||||
|
@ -56,8 +56,7 @@ class SessionTest < Test::Unit::TestCase
|
|||
|
||||
@session.expects(:get).with(path,args)
|
||||
|
||||
redirects = [true, true, false]
|
||||
@session.stubs(:redirect?).returns(lambda { redirects.shift })
|
||||
@session.stubs(:redirect?).returns(true).then.returns(true).then.returns(false)
|
||||
@session.expects(:follow_redirect!).times(2)
|
||||
|
||||
@session.stubs(:status).returns(200)
|
||||
|
@ -69,8 +68,7 @@ class SessionTest < Test::Unit::TestCase
|
|||
|
||||
@session.expects(:post).with(path,args)
|
||||
|
||||
redirects = [true, true, false]
|
||||
@session.stubs(:redirect?).returns(lambda { redirects.shift })
|
||||
@session.stubs(:redirect?).returns(true).then.returns(true).then.returns(false)
|
||||
@session.expects(:follow_redirect!).times(2)
|
||||
|
||||
@session.stubs(:status).returns(200)
|
||||
|
@ -134,15 +132,102 @@ class SessionTest < Test::Unit::TestCase
|
|||
@session.head(path,params,headers)
|
||||
end
|
||||
|
||||
def test_xml_http_request
|
||||
def test_xml_http_request_deprecated_call
|
||||
path = "/index"; params = "blah"; headers = {:location => 'blah'}
|
||||
headers_after_xhr = headers.merge(
|
||||
"X-Requested-With" => "XMLHttpRequest",
|
||||
"Accept" => "text/javascript, text/html, application/xml, text/xml, */*"
|
||||
)
|
||||
@session.expects(:post).with(path,params,headers_after_xhr)
|
||||
@session.xml_http_request(path,params,headers)
|
||||
@session.expects(:process).with(:post,path,params,headers_after_xhr)
|
||||
assert_deprecated { @session.xml_http_request(path,params,headers) }
|
||||
end
|
||||
|
||||
def test_xml_http_request_get
|
||||
path = "/index"; params = "blah"; headers = {:location => 'blah'}
|
||||
headers_after_xhr = headers.merge(
|
||||
"X-Requested-With" => "XMLHttpRequest",
|
||||
"Accept" => "text/javascript, text/html, application/xml, text/xml, */*"
|
||||
)
|
||||
@session.expects(:process).with(:get,path,params,headers_after_xhr)
|
||||
@session.xml_http_request(:get,path,params,headers)
|
||||
end
|
||||
|
||||
def test_xml_http_request_post
|
||||
path = "/index"; params = "blah"; headers = {:location => 'blah'}
|
||||
headers_after_xhr = headers.merge(
|
||||
"X-Requested-With" => "XMLHttpRequest",
|
||||
"Accept" => "text/javascript, text/html, application/xml, text/xml, */*"
|
||||
)
|
||||
@session.expects(:process).with(:post,path,params,headers_after_xhr)
|
||||
@session.xml_http_request(:post,path,params,headers)
|
||||
end
|
||||
|
||||
def test_xml_http_request_put
|
||||
path = "/index"; params = "blah"; headers = {:location => 'blah'}
|
||||
headers_after_xhr = headers.merge(
|
||||
"X-Requested-With" => "XMLHttpRequest",
|
||||
"Accept" => "text/javascript, text/html, application/xml, text/xml, */*"
|
||||
)
|
||||
@session.expects(:process).with(:put,path,params,headers_after_xhr)
|
||||
@session.xml_http_request(:put,path,params,headers)
|
||||
end
|
||||
|
||||
def test_xml_http_request_delete
|
||||
path = "/index"; params = "blah"; headers = {:location => 'blah'}
|
||||
headers_after_xhr = headers.merge(
|
||||
"X-Requested-With" => "XMLHttpRequest",
|
||||
"Accept" => "text/javascript, text/html, application/xml, text/xml, */*"
|
||||
)
|
||||
@session.expects(:process).with(:delete,path,params,headers_after_xhr)
|
||||
@session.xml_http_request(:delete,path,params,headers)
|
||||
end
|
||||
|
||||
def test_xml_http_request_head
|
||||
path = "/index"; params = "blah"; headers = {:location => 'blah'}
|
||||
headers_after_xhr = headers.merge(
|
||||
"X-Requested-With" => "XMLHttpRequest",
|
||||
"Accept" => "text/javascript, text/html, application/xml, text/xml, */*"
|
||||
)
|
||||
@session.expects(:process).with(:head,path,params,headers_after_xhr)
|
||||
@session.xml_http_request(:head,path,params,headers)
|
||||
end
|
||||
end
|
||||
|
||||
class IntegrationTestTest < Test::Unit::TestCase
|
||||
|
||||
def setup
|
||||
@test = ::ActionController::IntegrationTest.new(:default_test)
|
||||
@test.class.stubs(:fixture_table_names).returns([])
|
||||
@session = @test.open_session
|
||||
end
|
||||
|
||||
def test_opens_new_session
|
||||
@test.class.expects(:fixture_table_names).times(2).returns(['foo'])
|
||||
|
||||
session1 = @test.open_session { |sess| }
|
||||
session2 = @test.open_session # implicit session
|
||||
|
||||
assert_equal ::ActionController::Integration::Session, session1.class
|
||||
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.
|
||||
# Integration tests have their own setup and teardown.
|
||||
class IntegrationTestUsesCorrectClass < ActionController::IntegrationTest
|
||||
|
||||
def self.fixture_table_names
|
||||
[]
|
||||
end
|
||||
|
||||
def test_integration_methods_called
|
||||
%w( get post head put delete ).each do |verb|
|
||||
assert_nothing_raised("'#{verb}' should use integration test methods") { send(verb, '/') }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# TODO
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue