Skip to content

Commit

Permalink
More integration test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Aug 18, 2008
1 parent f245658 commit dbb0abf
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions actionpack/test/controller/integration_test.rb
Expand Up @@ -265,6 +265,10 @@ def cookie_monster
cookies["cookie_3"] = "chocolate"
render :text => "Gone", :status => 410
end

def redirect
redirect_to :action => "get"
end
end

def test_get
Expand All @@ -274,6 +278,9 @@ def test_get
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)
Expand All @@ -290,6 +297,9 @@ def test_post
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)
Expand All @@ -308,6 +318,8 @@ def test_cookie_monster
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 nil, response.headers["Set-Cookie"]
assert_equal ["cookie_1=; path=/", "cookie_3=chocolate; path=/"], headers['set-cookie']
assert_equal [[], ["chocolate"]], response.headers["cookie"]
Expand All @@ -317,14 +329,28 @@ def test_cookie_monster
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

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"
c.connect "/:action"
end
end
yield
Expand Down

0 comments on commit dbb0abf

Please sign in to comment.