aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-05-02 15:21:19 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-05-02 15:21:19 -0700
commit186fee48c796b104b76ef69decb32ef396f435db (patch)
tree9f8b8c8c83af7bd2913c1283f51fd3c3492fea82 /actionpack/test/controller
parent945bf9c254b5bfb56df874c1a3f7f0f1e89dc8b8 (diff)
parent24affdc88c4a4af03ce1ec5b23c3def18b90effe (diff)
downloadrails-186fee48c796b104b76ef69decb32ef396f435db.tar.gz
rails-186fee48c796b104b76ef69decb32ef396f435db.tar.bz2
rails-186fee48c796b104b76ef69decb32ef396f435db.zip
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/action_pack_assertions_test.rb8
-rw-r--r--actionpack/test/controller/caching_test.rb2
-rw-r--r--actionpack/test/controller/cookie_test.rb17
-rw-r--r--actionpack/test/controller/filters_test.rb2
-rw-r--r--actionpack/test/controller/helper_test.rb20
-rw-r--r--actionpack/test/controller/redirect_test.rb6
-rw-r--r--actionpack/test/controller/render_test.rb22
-rw-r--r--actionpack/test/controller/send_file_test.rb8
-rw-r--r--actionpack/test/controller/test_test.rb4
9 files changed, 48 insertions, 41 deletions
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb
index 711640f9a9..60957a2f0e 100644
--- a/actionpack/test/controller/action_pack_assertions_test.rb
+++ b/actionpack/test/controller/action_pack_assertions_test.rb
@@ -514,9 +514,11 @@ class ActionPackHeaderTest < ActionController::TestCase
end
def test_rendering_xml_respects_content_type
- @response.headers['type'] = 'application/pdf'
- process :hello_xml_world
- assert_equal('application/pdf; charset=utf-8', @response.headers['Content-Type'])
+ pending do
+ @response.headers['type'] = 'application/pdf'
+ process :hello_xml_world
+ assert_equal('application/pdf; charset=utf-8', @response.headers['Content-Type'])
+ end
end
def test_render_text_with_custom_content_type
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index 10b904481d..6b9d1056a3 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -111,7 +111,7 @@ class PageCachingTest < ActionController::TestCase
end
def test_should_cache_ok_at_custom_path
- @request.stubs(:path).returns("/index.html")
+ @request.request_uri = "/index.html"
get :ok
assert_response :ok
assert File.exist?("#{FILE_STORE_PATH}/index.html")
diff --git a/actionpack/test/controller/cookie_test.rb b/actionpack/test/controller/cookie_test.rb
index c861982698..0f22714071 100644
--- a/actionpack/test/controller/cookie_test.rb
+++ b/actionpack/test/controller/cookie_test.rb
@@ -54,39 +54,38 @@ class CookieTest < ActionController::TestCase
def test_setting_cookie
get :authenticate
- assert_equal ["user_name=david; path=/"], @response.headers["Set-Cookie"]
+ assert_equal "user_name=david; path=/", @response.headers["Set-Cookie"]
assert_equal({"user_name" => "david"}, @response.cookies)
end
def test_setting_with_escapable_characters
get :set_with_with_escapable_characters
- assert_equal ["that+%26+guy=foo+%26+bar+%3D%3E+baz; path=/"], @response.headers["Set-Cookie"]
+ assert_equal "that+%26+guy=foo+%26+bar+%3D%3E+baz; path=/", @response.headers["Set-Cookie"]
assert_equal({"that & guy" => "foo & bar => baz"}, @response.cookies)
end
def test_setting_cookie_for_fourteen_days
get :authenticate_for_fourteen_days
- assert_equal ["user_name=david; path=/; expires=Mon, 10-Oct-2005 05:00:00 GMT"], @response.headers["Set-Cookie"]
+ assert_equal "user_name=david; path=/; expires=Mon, 10-Oct-2005 05:00:00 GMT", @response.headers["Set-Cookie"]
assert_equal({"user_name" => "david"}, @response.cookies)
end
def test_setting_cookie_for_fourteen_days_with_symbols
get :authenticate_for_fourteen_days_with_symbols
- assert_equal ["user_name=david; path=/; expires=Mon, 10-Oct-2005 05:00:00 GMT"], @response.headers["Set-Cookie"]
+ assert_equal "user_name=david; path=/; expires=Mon, 10-Oct-2005 05:00:00 GMT", @response.headers["Set-Cookie"]
assert_equal({"user_name" => "david"}, @response.cookies)
end
def test_setting_cookie_with_http_only
get :authenticate_with_http_only
- assert_equal ["user_name=david; path=/; HttpOnly"], @response.headers["Set-Cookie"]
+ assert_equal "user_name=david; path=/; HttpOnly", @response.headers["Set-Cookie"]
assert_equal({"user_name" => "david"}, @response.cookies)
end
def test_multiple_cookies
get :set_multiple_cookies
assert_equal 2, @response.cookies.size
- assert_equal "user_name=david; path=/; expires=Mon, 10-Oct-2005 05:00:00 GMT", @response.headers["Set-Cookie"][0]
- assert_equal "login=XJ-122; path=/", @response.headers["Set-Cookie"][1]
+ assert_equal "user_name=david; path=/; expires=Mon, 10-Oct-2005 05:00:00 GMT\nlogin=XJ-122; path=/", @response.headers["Set-Cookie"]
assert_equal({"login" => "XJ-122", "user_name" => "david"}, @response.cookies)
end
@@ -96,7 +95,7 @@ class CookieTest < ActionController::TestCase
def test_expiring_cookie
get :logout
- assert_equal ["user_name=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT"], @response.headers["Set-Cookie"]
+ assert_equal "user_name=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT", @response.headers["Set-Cookie"]
assert_equal({"user_name" => nil}, @response.cookies)
end
@@ -117,6 +116,6 @@ class CookieTest < ActionController::TestCase
def test_delete_cookie_with_path
get :delete_cookie_with_path
- assert_equal ["user_name=; path=/beaten; expires=Thu, 01-Jan-1970 00:00:00 GMT"], @response.headers["Set-Cookie"]
+ assert_equal "user_name=; path=/beaten; expires=Thu, 01-Jan-1970 00:00:00 GMT", @response.headers["Set-Cookie"]
end
end
diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb
index 9e74538310..5876f55420 100644
--- a/actionpack/test/controller/filters_test.rb
+++ b/actionpack/test/controller/filters_test.rb
@@ -603,7 +603,7 @@ class FilterTest < Test::Unit::TestCase
%w(foo bar baz).each do |action|
request = ActionController::TestRequest.new
request.query_parameters[:choose] = action
- response = DynamicDispatchController.process(request, ActionController::TestResponse.new)
+ response = Rack::MockResponse.new(*DynamicDispatchController.call(request.env))
assert_equal action, response.body
end
end
diff --git a/actionpack/test/controller/helper_test.rb b/actionpack/test/controller/helper_test.rb
index 58addc123d..e72bce1791 100644
--- a/actionpack/test/controller/helper_test.rb
+++ b/actionpack/test/controller/helper_test.rb
@@ -102,19 +102,19 @@ class HelperTest < Test::Unit::TestCase
end
def test_helper_for_nested_controller
- request = ActionController::TestRequest.new
- response = ActionController::TestResponse.new
+ request = ActionController::TestRequest.new
request.action = 'render_hello_world'
- assert_equal 'hello: Iz guuut!', Fun::GamesController.process(request, response).body
+ response = Rack::MockResponse.new(*Fun::GamesController.call(request.env))
+ assert_equal 'hello: Iz guuut!', response.body
end
def test_helper_for_acronym_controller
- request = ActionController::TestRequest.new
- response = ActionController::TestResponse.new
+ request = ActionController::TestRequest.new
request.action = 'test'
- assert_equal 'test: baz', Fun::PdfController.process(request, response).body
+ response = Rack::MockResponse.new(*Fun::PdfController.call(request.env))
+ assert_equal 'test: baz', response.body
end
def test_all_helpers
@@ -211,14 +211,16 @@ class IsolatedHelpersTest < Test::Unit::TestCase
end
def test_helper_in_a
- assert_raise(ActionView::TemplateError) { A.process(@request, @response) }
+ assert_raise(ActionView::TemplateError) { A.call(@request.env) }
end
def test_helper_in_b
- assert_equal 'B', B.process(@request, @response).body
+ response = Rack::MockResponse.new(*B.call(@request.env))
+ assert_equal 'B', response.body
end
def test_helper_in_c
- assert_equal 'C', C.process(@request, @response).body
+ response = Rack::MockResponse.new(*C.call(@request.env))
+ assert_equal 'C', response.body
end
end
diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb
index 91e21db854..9ad63a1c60 100644
--- a/actionpack/test/controller/redirect_test.rb
+++ b/actionpack/test/controller/redirect_test.rb
@@ -234,8 +234,10 @@ class RedirectTest < ActionController::TestCase
end
def test_redirect_with_partial_params
- get :module_redirect
- assert_redirected_to :action => 'hello_world'
+ pending do
+ get :module_redirect
+ assert_redirected_to :action => 'hello_world'
+ end
end
def test_redirect_to_nil
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index 023bf0eeaa..dd2dd7a502 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -1293,15 +1293,15 @@ class RenderTest < ActionController::TestCase
def test_head_with_symbolic_status
get :head_with_symbolic_status, :status => "ok"
- assert_equal "200 OK", @response.status
+ assert_equal 200, @response.status
assert_response :ok
get :head_with_symbolic_status, :status => "not_found"
- assert_equal "404 Not Found", @response.status
+ assert_equal 404, @response.status
assert_response :not_found
get :head_with_symbolic_status, :status => "no_content"
- assert_equal "204 No Content", @response.status
+ assert_equal 204, @response.status
assert !@response.headers.include?('Content-Length')
assert_response :no_content
@@ -1322,7 +1322,7 @@ class RenderTest < ActionController::TestCase
def test_head_with_string_status
get :head_with_string_status, :status => "404 Eat Dirt"
assert_equal 404, @response.response_code
- assert_equal "Eat Dirt", @response.message
+ assert_equal "Not Found", @response.message
assert_response :not_found
end
@@ -1590,7 +1590,7 @@ class EtagRenderTest < ActionController::TestCase
def test_render_against_etag_request_should_304_when_match
@request.if_none_match = etag_for("hello david")
get :render_hello_world_from_variable
- assert_equal "304 Not Modified", @response.status
+ assert_equal 304, @response.status
assert @response.body.empty?
end
@@ -1603,13 +1603,13 @@ class EtagRenderTest < ActionController::TestCase
def test_render_against_etag_request_should_200_when_no_match
@request.if_none_match = etag_for("hello somewhere else")
get :render_hello_world_from_variable
- assert_equal "200 OK", @response.status
+ assert_equal 200, @response.status
assert !@response.body.empty?
end
def test_render_should_not_set_etag_when_last_modified_has_been_specified
get :render_hello_world_with_last_modified_set
- assert_equal "200 OK", @response.status
+ assert_equal 200, @response.status
assert_not_nil @response.last_modified
assert_nil @response.etag
assert @response.body.present?
@@ -1623,11 +1623,11 @@ class EtagRenderTest < ActionController::TestCase
@request.if_none_match = expected_etag
get :render_hello_world_from_variable
- assert_equal "304 Not Modified", @response.status
+ assert_equal 304, @response.status
@request.if_none_match = "\"diftag\""
get :render_hello_world_from_variable
- assert_equal "200 OK", @response.status
+ assert_equal 200, @response.status
end
def render_with_404_shouldnt_have_etag
@@ -1695,7 +1695,7 @@ class LastModifiedRenderTest < ActionController::TestCase
def test_request_not_modified
@request.if_modified_since = @last_modified
get :conditional_hello
- assert_equal "304 Not Modified", @response.status
+ assert_equal 304, @response.status
assert @response.body.blank?, @response.body
assert_equal @last_modified, @response.headers['Last-Modified']
end
@@ -1710,7 +1710,7 @@ class LastModifiedRenderTest < ActionController::TestCase
def test_request_modified
@request.if_modified_since = 'Thu, 16 Jul 2008 00:00:00 GMT'
get :conditional_hello
- assert_equal "200 OK", @response.status
+ assert_equal 200, @response.status
assert !@response.body.blank?
assert_equal @last_modified, @response.headers['Last-Modified']
end
diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb
index 2e14a0a32c..6007ebef7a 100644
--- a/actionpack/test/controller/send_file_test.rb
+++ b/actionpack/test/controller/send_file_test.rb
@@ -44,12 +44,12 @@ class SendFileTest < ActionController::TestCase
response = nil
assert_nothing_raised { response = process('file') }
assert_not_nil response
- assert_kind_of Proc, response.body_parts
+ assert_kind_of Array, response.body_parts
require 'stringio'
output = StringIO.new
output.binmode
- assert_nothing_raised { response.body_parts.call(response, output) }
+ assert_nothing_raised { response.body_parts.each { |part| output << part.to_s } }
assert_equal file_data, output.string
end
@@ -149,13 +149,13 @@ class SendFileTest < ActionController::TestCase
define_method "test_send_#{method}_status" do
@controller.options = { :stream => false, :status => 500 }
assert_nothing_raised { assert_not_nil process(method) }
- assert_equal '500 Internal Server Error', @response.status
+ assert_equal 500, @response.status
end
define_method "test_default_send_#{method}_status" do
@controller.options = { :stream => false }
assert_nothing_raised { assert_not_nil process(method) }
- assert_equal ActionController::DEFAULT_RENDER_STATUS_CODE, @response.status
+ assert_equal 200, @response.status
end
end
end
diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb
index 919f9815ec..9e88188b9a 100644
--- a/actionpack/test/controller/test_test.rb
+++ b/actionpack/test/controller/test_test.rb
@@ -614,7 +614,9 @@ XML
def test_binary_content_works_with_send_file
get :test_send_file
- assert_nothing_raised(NoMethodError) { @response.binary_content }
+ assert_deprecated do
+ assert_nothing_raised(NoMethodError) { @response.binary_content }
+ end
end
protected