Instiki 0.16.3: Rails 2.3.0
Instiki now runs on the Rails 2.3.0 Candidate Release. Among other improvements, this means that it now automagically selects between WEBrick and Mongrel. Just run ./instiki --daemon
This commit is contained in:
parent
43aadecc99
commit
4e14ccc74d
893 changed files with 71965 additions and 28511 deletions
|
@ -1,22 +1,14 @@
|
|||
require 'abstract_unit'
|
||||
require 'action_controller/integration'
|
||||
require 'action_controller/routing'
|
||||
|
||||
uses_mocha 'integration' do
|
||||
|
||||
module IntegrationSessionStubbing
|
||||
def stub_integration_session(session)
|
||||
session.stubs(:process)
|
||||
session.stubs(:generic_url_rewriter)
|
||||
end
|
||||
end
|
||||
|
||||
class SessionTest < Test::Unit::TestCase
|
||||
include IntegrationSessionStubbing
|
||||
StubApp = lambda { |env|
|
||||
[200, {"Content-Type" => "text/html", "Content-Length" => "13"}, "Hello, World!"]
|
||||
}
|
||||
|
||||
def setup
|
||||
@session = ActionController::Integration::Session.new
|
||||
stub_integration_session(@session)
|
||||
@session = ActionController::Integration::Session.new(StubApp)
|
||||
end
|
||||
|
||||
def test_https_bang_works_and_sets_truth_by_default
|
||||
|
@ -38,14 +30,6 @@ class SessionTest < Test::Unit::TestCase
|
|||
assert_raise(RuntimeError) { @session.follow_redirect! }
|
||||
end
|
||||
|
||||
def test_follow_redirect_calls_get_and_returns_status
|
||||
@session.stubs(:redirect?).returns(true)
|
||||
@session.stubs(:headers).returns({"location" => ["www.google.com"]})
|
||||
@session.stubs(:status).returns(200)
|
||||
@session.expects(:get)
|
||||
assert_equal 200, @session.follow_redirect!
|
||||
end
|
||||
|
||||
def test_request_via_redirect_uses_given_method
|
||||
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"}
|
||||
@session.expects(:put).with(path, args, headers)
|
||||
|
@ -209,13 +193,10 @@ class SessionTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
class IntegrationTestTest < Test::Unit::TestCase
|
||||
include IntegrationSessionStubbing
|
||||
|
||||
def setup
|
||||
@test = ::ActionController::IntegrationTest.new(:default_test)
|
||||
@test.class.stubs(:fixture_table_names).returns([])
|
||||
@session = @test.open_session
|
||||
stub_integration_session(@session)
|
||||
end
|
||||
|
||||
def test_opens_new_session
|
||||
|
@ -233,15 +214,15 @@ 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
|
||||
include IntegrationSessionStubbing
|
||||
|
||||
def self.fixture_table_names
|
||||
[]
|
||||
end
|
||||
|
||||
def test_integration_methods_called
|
||||
reset!
|
||||
stub_integration_session(@integration_session)
|
||||
@integration_session.stubs(:generic_url_rewriter)
|
||||
@integration_session.stubs(:process)
|
||||
|
||||
%w( get post head put delete ).each do |verb|
|
||||
assert_nothing_raised("'#{verb}' should use integration test methods") { __send__(verb, '/') }
|
||||
end
|
||||
|
@ -250,8 +231,6 @@ end
|
|||
|
||||
class IntegrationProcessTest < ActionController::IntegrationTest
|
||||
class IntegrationController < ActionController::Base
|
||||
session :off
|
||||
|
||||
def get
|
||||
respond_to do |format|
|
||||
format.html { render :text => "OK", :status => 200 }
|
||||
|
@ -283,14 +262,11 @@ class IntegrationProcessTest < ActionController::IntegrationTest
|
|||
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", body
|
||||
assert_equal "OK", response.body
|
||||
assert_kind_of HTML::Document, html_document
|
||||
assert_equal 1, request_count
|
||||
|
@ -302,14 +278,11 @@ class IntegrationProcessTest < ActionController::IntegrationTest
|
|||
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", body
|
||||
assert_equal "Created", response.body
|
||||
assert_kind_of HTML::Document, html_document
|
||||
assert_equal 1, request_count
|
||||
|
@ -323,17 +296,9 @@ class IntegrationProcessTest < ActionController::IntegrationTest
|
|||
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=; path=/", "cookie_3=chocolate; path=/"], headers["Set-Cookie"]
|
||||
assert_equal({"cookie_1"=>"", "cookie_2"=>"oatmeal", "cookie_3"=>"chocolate"}, cookies)
|
||||
assert_equal "Gone", response.body
|
||||
end
|
||||
|
@ -344,14 +309,16 @@ class IntegrationProcessTest < ActionController::IntegrationTest
|
|||
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
|
||||
|
||||
follow_redirect!
|
||||
assert_response :success
|
||||
assert_equal "/get", path
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -360,8 +327,6 @@ class IntegrationProcessTest < ActionController::IntegrationTest
|
|||
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
|
||||
|
@ -374,7 +339,7 @@ class IntegrationProcessTest < ActionController::IntegrationTest
|
|||
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 "", request.env["QUERY_STRING"]
|
||||
assert_equal 'foo=bar', request.query_string
|
||||
assert_equal 'bar', request.parameters['foo']
|
||||
|
||||
|
@ -397,6 +362,18 @@ class IntegrationProcessTest < ActionController::IntegrationTest
|
|||
end
|
||||
end
|
||||
|
||||
def test_head
|
||||
with_test_route_set do
|
||||
head '/get'
|
||||
assert_equal 200, status
|
||||
assert_equal "", body
|
||||
|
||||
head '/post'
|
||||
assert_equal 201, status
|
||||
assert_equal "", body
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def with_test_route_set
|
||||
with_routing do |set|
|
||||
|
@ -410,4 +387,35 @@ class IntegrationProcessTest < ActionController::IntegrationTest
|
|||
end
|
||||
end
|
||||
|
||||
class MetalTest < ActionController::IntegrationTest
|
||||
class Poller
|
||||
def self.call(env)
|
||||
if env["PATH_INFO"] =~ /^\/success/
|
||||
[200, {"Content-Type" => "text/plain", "Content-Length" => "12"}, "Hello World!"]
|
||||
else
|
||||
[404, {"Content-Type" => "text/plain", "Content-Length" => "0"}, '']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def setup
|
||||
@integration_session = ActionController::Integration::Session.new(Poller)
|
||||
end
|
||||
|
||||
def test_successful_get
|
||||
get "/success"
|
||||
assert_response 200
|
||||
assert_response :success
|
||||
assert_response :ok
|
||||
assert_equal "Hello World!", response.body
|
||||
end
|
||||
|
||||
def test_failed_get
|
||||
get "/failure"
|
||||
assert_response 404
|
||||
assert_response :not_found
|
||||
assert_equal '', response.body
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue