aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/abstract_controller/abstract_controller_test.rb22
-rw-r--r--actionpack/test/abstract_controller/layouts_test.rb4
-rw-r--r--actionpack/test/activerecord/polymorphic_routes_test.rb394
-rw-r--r--actionpack/test/controller/dispatcher_test.rb2
-rw-r--r--actionpack/test/controller/polymorphic_routes_test.rb293
-rw-r--r--actionpack/test/controller/rescue_test.rb96
-rw-r--r--actionpack/test/dispatch/request/multipart_params_parsing_test.rb4
-rw-r--r--actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb4
-rw-r--r--actionpack/test/dispatch/session/cookie_store_test.rb (renamed from actionpack/test/controller/session/cookie_store_test.rb)0
-rw-r--r--actionpack/test/dispatch/session/mem_cache_store_test.rb (renamed from actionpack/test/controller/session/mem_cache_store_test.rb)0
-rw-r--r--actionpack/test/dispatch/session/test_session_test.rb (renamed from actionpack/test/controller/session/test_session_test.rb)0
11 files changed, 501 insertions, 318 deletions
diff --git a/actionpack/test/abstract_controller/abstract_controller_test.rb b/actionpack/test/abstract_controller/abstract_controller_test.rb
index 6d33888821..918062c7db 100644
--- a/actionpack/test/abstract_controller/abstract_controller_test.rb
+++ b/actionpack/test/abstract_controller/abstract_controller_test.rb
@@ -56,6 +56,14 @@ module AbstractController
def naked_render
render
end
+
+ def rendering_to_body
+ render_to_body "naked_render.erb"
+ end
+
+ def rendering_to_string
+ render_to_string "naked_render.erb"
+ end
end
class TestRenderer < ActiveSupport::TestCase
@@ -73,6 +81,16 @@ module AbstractController
result = Me2.process(:naked_render)
assert_equal "Hello from naked_render.erb", result.response_obj[:body]
end
+
+ test "rendering to a rack body" do
+ result = Me2.process(:rendering_to_body)
+ assert_equal "Hello from naked_render.erb", result.response_obj[:body]
+ end
+
+ test "rendering to a string" do
+ result = Me2.process(:rendering_to_string)
+ assert_equal "Hello from naked_render.erb", result.response_obj[:body]
+ end
end
# Test rendering with prefixes
@@ -134,7 +152,7 @@ module AbstractController
self.class.layout(formats)
end
- def render_to_string(options = {})
+ def render_to_body(options = {})
options[:_layout] = options[:layout] || _layout
super
end
@@ -223,4 +241,4 @@ module AbstractController
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/test/abstract_controller/layouts_test.rb b/actionpack/test/abstract_controller/layouts_test.rb
index 5dd68ec28e..3d4570bfef 100644
--- a/actionpack/test/abstract_controller/layouts_test.rb
+++ b/actionpack/test/abstract_controller/layouts_test.rb
@@ -23,7 +23,7 @@ module AbstractControllerTests
def controller_path() self.class.controller_path end
- def render_to_string(options)
+ def render_to_body(options)
options[:_layout] = _default_layout
super
end
@@ -229,4 +229,4 @@ module AbstractControllerTests
end
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/test/activerecord/polymorphic_routes_test.rb b/actionpack/test/activerecord/polymorphic_routes_test.rb
new file mode 100644
index 0000000000..35139fbb7f
--- /dev/null
+++ b/actionpack/test/activerecord/polymorphic_routes_test.rb
@@ -0,0 +1,394 @@
+require 'active_record_unit'
+
+class Task < ActiveRecord::Base
+ set_table_name 'projects'
+end
+
+class Step < ActiveRecord::Base
+ set_table_name 'projects'
+end
+
+class Bid < ActiveRecord::Base
+ set_table_name 'projects'
+end
+
+class Tax < ActiveRecord::Base
+ set_table_name 'projects'
+end
+
+class Fax < ActiveRecord::Base
+ set_table_name 'projects'
+end
+
+class Series < ActiveRecord::Base
+ set_table_name 'projects'
+end
+
+class PolymorphicRoutesTest < ActionController::TestCase
+ include ActionController::UrlWriter
+ self.default_url_options[:host] = 'example.com'
+
+ def setup
+ @project = Project.new
+ @task = Task.new
+ @step = Step.new
+ @bid = Bid.new
+ @tax = Tax.new
+ @fax = Fax.new
+ @series = Series.new
+ end
+
+ def test_with_record
+ with_test_routes do
+ @project.save
+ assert_equal "http://example.com/projects/#{@project.id}", polymorphic_url(@project)
+ end
+ end
+
+ def test_with_new_record
+ with_test_routes do
+ assert_equal "http://example.com/projects", polymorphic_url(@project)
+ end
+ end
+
+ def test_with_record_and_action
+ with_test_routes do
+ assert_equal "http://example.com/projects/new", polymorphic_url(@project, :action => 'new')
+ end
+ end
+
+ def test_url_helper_prefixed_with_new
+ with_test_routes do
+ assert_equal "http://example.com/projects/new", new_polymorphic_url(@project)
+ end
+ end
+
+ def test_url_helper_prefixed_with_edit
+ with_test_routes do
+ @project.save
+ assert_equal "http://example.com/projects/#{@project.id}/edit", edit_polymorphic_url(@project)
+ end
+ end
+
+ def test_url_helper_prefixed_with_edit_with_url_options
+ with_test_routes do
+ @project.save
+ assert_equal "http://example.com/projects/#{@project.id}/edit?param1=10", edit_polymorphic_url(@project, :param1 => '10')
+ end
+ end
+
+ def test_url_helper_with_url_options
+ with_test_routes do
+ @project.save
+ assert_equal "http://example.com/projects/#{@project.id}?param1=10", polymorphic_url(@project, :param1 => '10')
+ end
+ end
+
+ def test_formatted_url_helper_is_deprecated
+ with_test_routes do
+ assert_deprecated do
+ formatted_polymorphic_url([@project, :pdf])
+ end
+ end
+ end
+
+ def test_format_option
+ with_test_routes do
+ @project.save
+ assert_equal "http://example.com/projects/#{@project.id}.pdf", polymorphic_url(@project, :format => :pdf)
+ end
+ end
+
+ def test_format_option_with_url_options
+ with_test_routes do
+ @project.save
+ assert_equal "http://example.com/projects/#{@project.id}.pdf?param1=10", polymorphic_url(@project, :format => :pdf, :param1 => '10')
+ end
+ end
+
+ def test_id_and_format_option
+ with_test_routes do
+ @project.save
+ assert_equal "http://example.com/projects/#{@project.id}.pdf", polymorphic_url(:id => @project, :format => :pdf)
+ end
+ end
+
+ def test_with_nested
+ with_test_routes do
+ @project.save
+ @task.save
+ assert_equal "http://example.com/projects/#{@project.id}/tasks/#{@task.id}", polymorphic_url([@project, @task])
+ end
+ end
+
+ def test_with_nested_unsaved
+ with_test_routes do
+ @project.save
+ assert_equal "http://example.com/projects/#{@project.id}/tasks", polymorphic_url([@project, @task])
+ end
+ end
+
+ def test_new_with_array_and_namespace
+ with_admin_test_routes do
+ assert_equal "http://example.com/admin/projects/new", polymorphic_url([:admin, @project], :action => 'new')
+ end
+ end
+
+ def test_unsaved_with_array_and_namespace
+ with_admin_test_routes do
+ assert_equal "http://example.com/admin/projects", polymorphic_url([:admin, @project])
+ end
+ end
+
+ def test_nested_unsaved_with_array_and_namespace
+ with_admin_test_routes do
+ @project.save
+ assert_equal "http://example.com/admin/projects/#{@project.id}/tasks", polymorphic_url([:admin, @project, @task])
+ end
+ end
+
+ def test_nested_with_array_and_namespace
+ with_admin_test_routes do
+ @project.save
+ @task.save
+ assert_equal "http://example.com/admin/projects/#{@project.id}/tasks/#{@task.id}", polymorphic_url([:admin, @project, @task])
+ end
+ end
+
+ def test_ordering_of_nesting_and_namespace
+ with_admin_and_site_test_routes do
+ @project.save
+ @task.save
+ @step.save
+ assert_equal "http://example.com/admin/projects/#{@project.id}/site/tasks/#{@task.id}/steps/#{@step.id}", polymorphic_url([:admin, @project, :site, @task, @step])
+ end
+ end
+
+ def test_nesting_with_array_ending_in_singleton_resource
+ with_test_routes do
+ @project.save
+ assert_equal "http://example.com/projects/#{@project.id}/bid", polymorphic_url([@project, :bid])
+ end
+ end
+
+ def test_nesting_with_array_containing_singleton_resource
+ with_test_routes do
+ @project.save
+ @task.save
+ assert_equal "http://example.com/projects/#{@project.id}/bid/tasks/#{@task.id}", polymorphic_url([@project, :bid, @task])
+ end
+ end
+
+ def test_nesting_with_array_containing_singleton_resource_and_format
+ with_test_routes do
+ @project.save
+ @task.save
+ assert_equal "http://example.com/projects/#{@project.id}/bid/tasks/#{@task.id}.pdf", polymorphic_url([@project, :bid, @task], :format => :pdf)
+ end
+ end
+
+ def test_nesting_with_array_containing_namespace_and_singleton_resource
+ with_admin_test_routes do
+ @project.save
+ @task.save
+ assert_equal "http://example.com/admin/projects/#{@project.id}/bid/tasks/#{@task.id}", polymorphic_url([:admin, @project, :bid, @task])
+ end
+ end
+
+ def test_nesting_with_array_containing_nil
+ with_test_routes do
+ @project.save
+ assert_equal "http://example.com/projects/#{@project.id}/bid", polymorphic_url([@project, nil, :bid])
+ end
+ end
+
+ def test_with_array_containing_single_object
+ with_test_routes do
+ @project.save
+ assert_equal "http://example.com/projects/#{@project.id}", polymorphic_url([nil, @project])
+ end
+ end
+
+ def test_with_array_containing_single_name
+ with_test_routes do
+ @project.save
+ assert_equal "http://example.com/projects", polymorphic_url([:projects])
+ end
+ end
+
+ def test_with_hash
+ with_test_routes do
+ @project.save
+ assert_equal "http://example.com/projects/#{@project.id}", polymorphic_url(:id => @project)
+ end
+ end
+
+ def test_polymorphic_path_accepts_options
+ with_test_routes do
+ assert_equal "/projects/new", polymorphic_path(@project, :action => 'new')
+ end
+ end
+
+ def test_polymorphic_path_does_not_modify_arguments
+ with_admin_test_routes do
+ @project.save
+ @task.save
+ object_array = [:admin, @project, @task]
+ assert_no_difference 'object_array.size' do
+ polymorphic_url(object_array)
+ end
+ end
+ end
+
+ # Tests for names where .plural.singular doesn't round-trip
+ def test_with_irregular_plural_record
+ with_test_routes do
+ @tax.save
+ assert_equal "http://example.com/taxes/#{@tax.id}", polymorphic_url(@tax)
+ end
+ end
+
+ def test_with_irregular_plural_new_record
+ with_test_routes do
+ assert_equal "http://example.com/taxes", polymorphic_url(@tax)
+ end
+ end
+
+ def test_with_irregular_plural_record_and_action
+ with_test_routes do
+ assert_equal "http://example.com/taxes/new", polymorphic_url(@tax, :action => 'new')
+ end
+ end
+
+ def test_irregular_plural_url_helper_prefixed_with_new
+ with_test_routes do
+ assert_equal "http://example.com/taxes/new", new_polymorphic_url(@tax)
+ end
+ end
+
+ def test_irregular_plural_url_helper_prefixed_with_edit
+ with_test_routes do
+ @tax.save
+ assert_equal "http://example.com/taxes/#{@tax.id}/edit", edit_polymorphic_url(@tax)
+ end
+ end
+
+ def test_with_nested_irregular_plurals
+ with_test_routes do
+ @tax.save
+ @fax.save
+ assert_equal "http://example.com/taxes/#{@tax.id}/faxes/#{@fax.id}", polymorphic_url([@tax, @fax])
+ end
+ end
+
+ def test_with_nested_unsaved_irregular_plurals
+ with_test_routes do
+ @tax.save
+ assert_equal "http://example.com/taxes/#{@tax.id}/faxes", polymorphic_url([@tax, @fax])
+ end
+ end
+
+ def test_new_with_irregular_plural_array_and_namespace
+ with_admin_test_routes do
+ assert_equal "http://example.com/admin/taxes/new", polymorphic_url([:admin, @tax], :action => 'new')
+ end
+ end
+
+ def test_unsaved_with_irregular_plural_array_and_namespace
+ with_admin_test_routes do
+ assert_equal "http://example.com/admin/taxes", polymorphic_url([:admin, @tax])
+ end
+ end
+
+ def test_nesting_with_irregular_plurals_and_array_ending_in_singleton_resource
+ with_test_routes do
+ @tax.save
+ assert_equal "http://example.com/taxes/#{@tax.id}/bid", polymorphic_url([@tax, :bid])
+ end
+ end
+
+ def test_with_array_containing_single_irregular_plural_object
+ with_test_routes do
+ @tax.save
+ assert_equal "http://example.com/taxes/#{@tax.id}", polymorphic_url([nil, @tax])
+ end
+ end
+
+ def test_with_array_containing_single_name_irregular_plural
+ with_test_routes do
+ @tax.save
+ assert_equal "http://example.com/taxes", polymorphic_url([:taxes])
+ end
+ end
+
+ # Tests for uncountable names
+ def test_uncountable_resource
+ with_test_routes do
+ @series.save
+ assert_equal "http://example.com/series/#{@series.id}", polymorphic_url(@series)
+ end
+ end
+
+ def with_test_routes(options = {})
+ with_routing do |set|
+ set.draw do |map|
+ map.resources :projects do |projects|
+ projects.resources :tasks
+ projects.resource :bid do |bid|
+ bid.resources :tasks
+ end
+ end
+ map.resources :taxes do |taxes|
+ taxes.resources :faxes
+ taxes.resource :bid
+ end
+ map.resources :series
+ end
+
+ ActionController::Routing::Routes.install_helpers(self.class)
+ yield
+ end
+ end
+
+ def with_admin_test_routes(options = {})
+ with_routing do |set|
+ set.draw do |map|
+ map.namespace :admin do |admin|
+ admin.resources :projects do |projects|
+ projects.resources :tasks
+ projects.resource :bid do |bid|
+ bid.resources :tasks
+ end
+ end
+ admin.resources :taxes do |taxes|
+ taxes.resources :faxes
+ end
+ admin.resources :series
+ end
+ end
+
+ ActionController::Routing::Routes.install_helpers(self.class)
+ yield
+ end
+ end
+
+ def with_admin_and_site_test_routes(options = {})
+ with_routing do |set|
+ set.draw do |map|
+ map.namespace :admin do |admin|
+ admin.resources :projects do |projects|
+ projects.namespace :site do |site|
+ site.resources :tasks do |tasks|
+ tasks.resources :steps
+ end
+ end
+ end
+ end
+ end
+
+ ActionController::Routing::Routes.install_helpers(self.class)
+ yield
+ end
+ end
+
+end \ No newline at end of file
diff --git a/actionpack/test/controller/dispatcher_test.rb b/actionpack/test/controller/dispatcher_test.rb
index 721bcf6136..569d698a03 100644
--- a/actionpack/test/controller/dispatcher_test.rb
+++ b/actionpack/test/controller/dispatcher_test.rb
@@ -94,7 +94,7 @@ class DispatcherTest < Test::Unit::TestCase
def dispatch(cache_classes = true)
ActionController::Routing::RouteSet.any_instance.stubs(:call).returns([200, {}, 'response'])
Dispatcher.define_dispatcher_callbacks(cache_classes)
- Dispatcher.new.call({})
+ Dispatcher.new.call({'rack.input' => StringIO.new('')})
end
def assert_subclasses(howmany, klass, message = klass.subclasses.inspect)
diff --git a/actionpack/test/controller/polymorphic_routes_test.rb b/actionpack/test/controller/polymorphic_routes_test.rb
deleted file mode 100644
index 146d703619..0000000000
--- a/actionpack/test/controller/polymorphic_routes_test.rb
+++ /dev/null
@@ -1,293 +0,0 @@
-require 'abstract_unit'
-
-class Article
- attr_reader :id
- def save; @id = 1 end
- def new_record?; @id.nil? end
- def name
- model = self.class.name.downcase
- @id.nil? ? "new #{model}" : "#{model} ##{@id}"
- end
-end
-
-class Response < Article
- def post_id; 1 end
-end
-
-class Tag < Article
- def response_id; 1 end
-end
-
-class Tax
- attr_reader :id
- def save; @id = 1 end
- def new_record?; @id.nil? end
- def name
- model = self.class.name.downcase
- @id.nil? ? "new #{model}" : "#{model} ##{@id}"
- end
-end
-
-class Fax < Tax
- def store_id; 1 end
-end
-
-# TODO: test nested models
-class Response::Nested < Response; end
-
-class PolymorphicRoutesTest < ActiveSupport::TestCase
- include ActionController::PolymorphicRoutes
-
- def setup
- @article = Article.new
- @response = Response.new
- @tax = Tax.new
- @fax = Fax.new
- end
-
- def test_with_record
- @article.save
- expects(:article_url).with(@article)
- polymorphic_url(@article)
- end
-
- def test_with_new_record
- expects(:articles_url).with()
- @article.expects(:new_record?).returns(true)
- polymorphic_url(@article)
- end
-
- def test_with_record_and_action
- expects(:new_article_url).with()
- @article.expects(:new_record?).never
- polymorphic_url(@article, :action => 'new')
- end
-
- def test_url_helper_prefixed_with_new
- expects(:new_article_url).with()
- new_polymorphic_url(@article)
- end
-
- def test_url_helper_prefixed_with_edit
- @article.save
- expects(:edit_article_url).with(@article)
- edit_polymorphic_url(@article)
- end
-
- def test_url_helper_prefixed_with_edit_with_url_options
- @article.save
- expects(:edit_article_url).with(@article, :param1 => '10')
- edit_polymorphic_url(@article, :param1 => '10')
- end
-
- def test_url_helper_with_url_options
- @article.save
- expects(:article_url).with(@article, :param1 => '10')
- polymorphic_url(@article, :param1 => '10')
- end
-
- def test_formatted_url_helper_is_deprecated
- expects(:articles_url).with(:format => :pdf)
- assert_deprecated do
- formatted_polymorphic_url([@article, :pdf])
- end
- end
-
- def test_format_option
- @article.save
- expects(:article_url).with(@article, :format => :pdf)
- polymorphic_url(@article, :format => :pdf)
- end
-
- def test_format_option_with_url_options
- @article.save
- expects(:article_url).with(@article, :format => :pdf, :param1 => '10')
- polymorphic_url(@article, :format => :pdf, :param1 => '10')
- end
-
- def test_id_and_format_option
- @article.save
- expects(:article_url).with(:id => @article, :format => :pdf)
- polymorphic_url(:id => @article, :format => :pdf)
- end
-
- def test_with_nested
- @response.save
- expects(:article_response_url).with(@article, @response)
- polymorphic_url([@article, @response])
- end
-
- def test_with_nested_unsaved
- expects(:article_responses_url).with(@article)
- polymorphic_url([@article, @response])
- end
-
- def test_new_with_array_and_namespace
- expects(:new_admin_article_url).with()
- polymorphic_url([:admin, @article], :action => 'new')
- end
-
- def test_unsaved_with_array_and_namespace
- expects(:admin_articles_url).with()
- polymorphic_url([:admin, @article])
- end
-
- def test_nested_unsaved_with_array_and_namespace
- @article.save
- expects(:admin_article_url).with(@article)
- polymorphic_url([:admin, @article])
- expects(:admin_article_responses_url).with(@article)
- polymorphic_url([:admin, @article, @response])
- end
-
- def test_nested_with_array_and_namespace
- @response.save
- expects(:admin_article_response_url).with(@article, @response)
- polymorphic_url([:admin, @article, @response])
-
- # a ridiculously long named route tests correct ordering of namespaces and nesting:
- @tag = Tag.new
- @tag.save
- expects(:site_admin_article_response_tag_url).with(@article, @response, @tag)
- polymorphic_url([:site, :admin, @article, @response, @tag])
- end
-
- def test_nesting_with_array_ending_in_singleton_resource
- expects(:article_response_url).with(@article)
- polymorphic_url([@article, :response])
- end
-
- def test_nesting_with_array_containing_singleton_resource
- @tag = Tag.new
- @tag.save
- expects(:article_response_tag_url).with(@article, @tag)
- polymorphic_url([@article, :response, @tag])
- end
-
- def test_nesting_with_array_containing_namespace_and_singleton_resource
- @tag = Tag.new
- @tag.save
- expects(:admin_article_response_tag_url).with(@article, @tag)
- polymorphic_url([:admin, @article, :response, @tag])
- end
-
- def test_nesting_with_array_containing_singleton_resource_and_format
- @tag = Tag.new
- @tag.save
- expects(:article_response_tag_url).with(@article, @tag, :format => :pdf)
- polymorphic_url([@article, :response, @tag], :format => :pdf)
- end
-
- def test_nesting_with_array_containing_singleton_resource_and_format_option
- @tag = Tag.new
- @tag.save
- expects(:article_response_tag_url).with(@article, @tag, :format => :pdf)
- polymorphic_url([@article, :response, @tag], :format => :pdf)
- end
-
- def test_nesting_with_array_containing_nil
- expects(:article_response_url).with(@article)
- polymorphic_url([@article, nil, :response])
- end
-
- def test_with_array_containing_single_object
- @article.save
- expects(:article_url).with(@article)
- polymorphic_url([nil, @article])
- end
-
- def test_with_array_containing_single_name
- @article.save
- expects(:articles_url)
- polymorphic_url([:articles])
- end
-
- # TODO: Needs to be updated to correctly know about whether the object is in a hash or not
- def xtest_with_hash
- expects(:article_url).with(@article)
- @article.save
- polymorphic_url(:id => @article)
- end
-
- def test_polymorphic_path_accepts_options
- expects(:new_article_path).with()
- polymorphic_path(@article, :action => :new)
- end
-
- def test_polymorphic_path_does_not_modify_arguments
- expects(:admin_article_responses_url).with(@article)
- path = [:admin, @article, @response]
- assert_no_difference 'path.size' do
- polymorphic_url(path)
- end
- end
-
- # Tests for names where .plural.singular doesn't round-trip
- def test_with_irregular_plural_record
- @tax.save
- expects(:taxis_url).with(@tax)
- polymorphic_url(@tax)
- end
-
- def test_with_irregular_plural_new_record
- expects(:taxes_url).with()
- @tax.expects(:new_record?).returns(true)
- polymorphic_url(@tax)
- end
-
- def test_with_irregular_plural_record_and_action
- expects(:new_taxis_url).with()
- @tax.expects(:new_record?).never
- polymorphic_url(@tax, :action => 'new')
- end
-
- def test_irregular_plural_url_helper_prefixed_with_new
- expects(:new_taxis_url).with()
- new_polymorphic_url(@tax)
- end
-
- def test_irregular_plural_url_helper_prefixed_with_edit
- @tax.save
- expects(:edit_taxis_url).with(@tax)
- edit_polymorphic_url(@tax)
- end
-
- def test_with_nested_irregular_plurals
- @fax.save
- expects(:taxis_faxis_url).with(@tax, @fax)
- polymorphic_url([@tax, @fax])
- end
-
- def test_with_nested_unsaved_irregular_plurals
- expects(:taxis_faxes_url).with(@tax)
- polymorphic_url([@tax, @fax])
- end
-
- def test_new_with_irregular_plural_array_and_namespace
- expects(:new_admin_taxis_url).with()
- polymorphic_url([:admin, @tax], :action => 'new')
- end
-
- def test_unsaved_with_irregular_plural_array_and_namespace
- expects(:admin_taxes_url).with()
- polymorphic_url([:admin, @tax])
- end
-
- def test_nesting_with_irregular_plurals_and_array_ending_in_singleton_resource
- expects(:taxis_faxis_url).with(@tax)
- polymorphic_url([@tax, :faxis])
- end
-
- def test_with_array_containing_single_irregular_plural_object
- @tax.save
- expects(:taxis_url).with(@tax)
- polymorphic_url([nil, @tax])
- end
-
- def test_with_array_containing_single_name_irregular_plural
- @tax.save
- expects(:taxes_url)
- polymorphic_url([:taxes])
- end
-
-end
diff --git a/actionpack/test/controller/rescue_test.rb b/actionpack/test/controller/rescue_test.rb
index 741b01caa8..894420a910 100644
--- a/actionpack/test/controller/rescue_test.rb
+++ b/actionpack/test/controller/rescue_test.rb
@@ -400,22 +400,6 @@ class RescueControllerTest < ActionController::TestCase
assert_equal "RescueController::ResourceUnavailableToRescueAsString", @response.body
end
- def test_rescue_dispatcher_exceptions
- env = @request.env
- env["action_controller.rescue.request"] = @request
- env["action_controller.rescue.response"] = @response
-
- RescueController.call_with_exception(env, ActionController::RoutingError.new("Route not found"))
- assert_equal "no way", @response.body
- end
-
- def test_rescue_dispatcher_exceptions_without_request_set
- @request.env['REQUEST_URI'] = '/no_way'
- response = RescueController.call_with_exception(@request.env, ActionController::RoutingError.new("Route not found"))
- assert_kind_of ActionDispatch::Response, response
- assert_equal "no way", response.body
- end
-
protected
def with_all_requests_local(local = true)
old_local, ActionController::Base.consider_all_requests_local =
@@ -537,3 +521,83 @@ class ControllerInheritanceRescueControllerTest < ActionController::TestCase
assert_response :created
end
end
+
+class ApplicationController < ActionController::Base
+ rescue_from ActionController::RoutingError do
+ render :text => 'no way'
+ end
+end
+
+class RescueTest < ActionController::IntegrationTest
+ class TestController < ActionController::Base
+ class RecordInvalid < StandardError
+ def message
+ 'invalid'
+ end
+ end
+ rescue_from RecordInvalid, :with => :show_errors
+
+ def foo
+ render :text => "foo"
+ end
+
+ def invalid
+ raise RecordInvalid
+ end
+
+ def b00m
+ raise 'b00m'
+ end
+
+ protected
+ def show_errors(exception)
+ render :text => exception.message
+ end
+ end
+
+ test 'normal request' do
+ with_test_routing do
+ get '/foo'
+ assert_equal 'foo', response.body
+ end
+ end
+
+ test 'rescue exceptions inside controller' do
+ with_test_routing do
+ get '/invalid'
+ assert_equal 'invalid', response.body
+ end
+ end
+
+ test 'rescue routing exceptions' do
+ assert_equal 1, ApplicationController.rescue_handlers.length
+
+ begin
+ with_test_routing do
+ get '/no_way'
+ assert_equal 'no way', response.body
+ end
+ ensure
+ ActionController::Base.rescue_handlers.clear
+ end
+ end
+
+ test 'unrescued exception' do
+ with_test_routing do
+ get '/b00m'
+ assert_match(/Action Controller: Exception caught/, response.body)
+ end
+ end
+
+ private
+ def with_test_routing
+ with_routing do |set|
+ set.draw do |map|
+ map.connect 'foo', :controller => "rescue_test/test", :action => 'foo'
+ map.connect 'invalid', :controller => "rescue_test/test", :action => 'invalid'
+ map.connect 'b00m', :controller => "rescue_test/test", :action => 'b00m'
+ end
+ yield
+ end
+ end
+end
diff --git a/actionpack/test/dispatch/request/multipart_params_parsing_test.rb b/actionpack/test/dispatch/request/multipart_params_parsing_test.rb
index 2f409f020d..88b81dc493 100644
--- a/actionpack/test/dispatch/request/multipart_params_parsing_test.rb
+++ b/actionpack/test/dispatch/request/multipart_params_parsing_test.rb
@@ -206,8 +206,8 @@ class MultipartParamsParsingTest < ActionController::IntegrationTest
end
def call(env)
- req = Rack::Request.new(env)
- req.params # Parse params
+ env['rack.input'].read
+ env['rack.input'].rewind
@app.call(env)
end
end
diff --git a/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb b/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
index 51a660f614..8de4a83d76 100644
--- a/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
+++ b/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
@@ -150,8 +150,8 @@ class UrlEncodedParamsParsingTest < ActionController::IntegrationTest
end
def call(env)
- req = Rack::Request.new(env)
- req.params # Parse params
+ env['rack.input'].read
+ env['rack.input'].rewind
@app.call(env)
end
end
diff --git a/actionpack/test/controller/session/cookie_store_test.rb b/actionpack/test/dispatch/session/cookie_store_test.rb
index b9bf8cf411..b9bf8cf411 100644
--- a/actionpack/test/controller/session/cookie_store_test.rb
+++ b/actionpack/test/dispatch/session/cookie_store_test.rb
diff --git a/actionpack/test/controller/session/mem_cache_store_test.rb b/actionpack/test/dispatch/session/mem_cache_store_test.rb
index 7561c93e4a..7561c93e4a 100644
--- a/actionpack/test/controller/session/mem_cache_store_test.rb
+++ b/actionpack/test/dispatch/session/mem_cache_store_test.rb
diff --git a/actionpack/test/controller/session/test_session_test.rb b/actionpack/test/dispatch/session/test_session_test.rb
index de6539e1cc..de6539e1cc 100644
--- a/actionpack/test/controller/session/test_session_test.rb
+++ b/actionpack/test/dispatch/session/test_session_test.rb