From 5170d210e84ab38fa93a1346ebe32b12e75d72bc Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Thu, 24 Mar 2011 23:24:47 +0100 Subject: correction to the outputted controller name in the diagnostics error template, test included Signed-off-by: Santiago Pastorino --- actionpack/test/dispatch/show_exceptions_test.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'actionpack/test/dispatch') diff --git a/actionpack/test/dispatch/show_exceptions_test.rb b/actionpack/test/dispatch/show_exceptions_test.rb index 2a478c214f..e453dd11ce 100644 --- a/actionpack/test/dispatch/show_exceptions_test.rb +++ b/actionpack/test/dispatch/show_exceptions_test.rb @@ -7,6 +7,8 @@ class ShowExceptionsTest < ActionDispatch::IntegrationTest case req.path when "/not_found" raise ActionController::UnknownAction + when "/runtime_error" + raise RuntimeError when "/method_not_allowed" raise ActionController::MethodNotAllowed when "/not_implemented" @@ -121,4 +123,18 @@ class ShowExceptionsTest < ActionDispatch::IntegrationTest assert_response 404 assert_match(/AbstractController::ActionNotFound/, body) end + + test "show the controller name in the diagnostics template when controller name is present" do + @app = ProductionApp + get("/runtime_error", {}, { + 'action_dispatch.show_exceptions' => true, + 'action_dispatch.request.parameters' => { + 'action' => 'show', + 'id' => 'unknown', + 'controller' => 'featured_tiles' + } + }) + assert_response 500 + assert_match(/RuntimeError\n in FeaturedTilesController/, body) + end end -- cgit v1.2.3 From 84a4ef63a4b890dc29cd62543f52c863fb0f0dd5 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Tue, 29 Mar 2011 03:01:46 +0700 Subject: Move mapper_test to the appropriate location It seems like in 89c5b9aee7d7db95cec9e5a934c3761872ab107e Aaron actually put the test in action_dispatch folder. However, there's already a `test/dispatch` directory which I think it's more appropriate. Signed-off-by: Andrew White --- actionpack/test/dispatch/mapper_test.rb | 88 +++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 actionpack/test/dispatch/mapper_test.rb (limited to 'actionpack/test/dispatch') diff --git a/actionpack/test/dispatch/mapper_test.rb b/actionpack/test/dispatch/mapper_test.rb new file mode 100644 index 0000000000..f90de735b6 --- /dev/null +++ b/actionpack/test/dispatch/mapper_test.rb @@ -0,0 +1,88 @@ +require 'abstract_unit' + +module ActionDispatch + module Routing + class MapperTest < ActiveSupport::TestCase + class FakeSet + attr_reader :routes + + def initialize + @routes = [] + end + + def resources_path_names + {} + end + + def request_class + ActionDispatch::Request + end + + def add_route(*args) + routes << args + end + + def conditions + routes.map { |x| x[1] } + end + + def requirements + routes.map { |x| x[2] } + end + end + + def test_initialize + Mapper.new FakeSet.new + end + + def test_map_slash + fakeset = FakeSet.new + mapper = Mapper.new fakeset + mapper.match '/', :to => 'posts#index', :as => :main + assert_equal '/', fakeset.conditions.first[:path_info] + end + + def test_map_more_slashes + fakeset = FakeSet.new + mapper = Mapper.new fakeset + + # FIXME: is this a desired behavior? + mapper.match '/one/two/', :to => 'posts#index', :as => :main + assert_equal '/one/two(.:format)', fakeset.conditions.first[:path_info] + end + + def test_map_wildcard + fakeset = FakeSet.new + mapper = Mapper.new fakeset + mapper.match '/*path', :to => 'pages#show' + assert_equal '/*path(.:format)', fakeset.conditions.first[:path_info] + assert_equal /.+?/, fakeset.requirements.first[:path] + end + + def test_map_wildcard_with_other_element + fakeset = FakeSet.new + mapper = Mapper.new fakeset + mapper.match '/*path/foo/:bar', :to => 'pages#show' + assert_equal '/*path/foo/:bar(.:format)', fakeset.conditions.first[:path_info] + assert_nil fakeset.requirements.first[:path] + end + + def test_map_wildcard_with_multiple_wildcard + fakeset = FakeSet.new + mapper = Mapper.new fakeset + mapper.match '/*foo/*bar', :to => 'pages#show' + assert_equal '/*foo/*bar(.:format)', fakeset.conditions.first[:path_info] + assert_nil fakeset.requirements.first[:foo] + assert_equal /.+?/, fakeset.requirements.first[:bar] + end + + def test_map_wildcard_with_format_false + fakeset = FakeSet.new + mapper = Mapper.new fakeset + mapper.match '/*path', :to => 'pages#show', :format => false + assert_equal '/*path', fakeset.conditions.first[:path_info] + assert_nil fakeset.requirements.first[:path] + end + end + end +end -- cgit v1.2.3 From 52351bcfeb833b00366f91e965c057f431b5a8aa Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Tue, 29 Mar 2011 09:40:42 -0300 Subject: Remove 'warning: ambiguous first argument' when running ActionPack tests Signed-off-by: Santiago Pastorino --- actionpack/test/dispatch/mapper_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack/test/dispatch') diff --git a/actionpack/test/dispatch/mapper_test.rb b/actionpack/test/dispatch/mapper_test.rb index f90de735b6..b6c08ffc33 100644 --- a/actionpack/test/dispatch/mapper_test.rb +++ b/actionpack/test/dispatch/mapper_test.rb @@ -56,7 +56,7 @@ module ActionDispatch mapper = Mapper.new fakeset mapper.match '/*path', :to => 'pages#show' assert_equal '/*path(.:format)', fakeset.conditions.first[:path_info] - assert_equal /.+?/, fakeset.requirements.first[:path] + assert_equal(/.+?/, fakeset.requirements.first[:path]) end def test_map_wildcard_with_other_element @@ -73,7 +73,7 @@ module ActionDispatch mapper.match '/*foo/*bar', :to => 'pages#show' assert_equal '/*foo/*bar(.:format)', fakeset.conditions.first[:path_info] assert_nil fakeset.requirements.first[:foo] - assert_equal /.+?/, fakeset.requirements.first[:bar] + assert_equal(/.+?/, fakeset.requirements.first[:bar]) end def test_map_wildcard_with_format_false -- cgit v1.2.3