From 557e19346ad144deecd7d76a8a4e4cec22a6597e Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 27 Jun 2007 08:38:55 +0000 Subject: Prefix nested resource named routes with their action name, e.g. new_group_user_path(@group) instead of group_new_user_path(@group). The old nested action named route is deprecated in Rails 1.2.4. Closes #8558. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7138 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/routing_test.rb | 38 +++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'actionpack/test/controller/routing_test.rb') diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 9e5e9e1617..758d37396a 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -1024,6 +1024,42 @@ class RouteTest < Test::Unit::TestCase end end +class MapperDeprecatedRouteTest < Test::Unit::TestCase + def setup + @set = mock("set") + @mapper = ActionController::Routing::RouteSet::Mapper.new(@set) + end + + def test_should_add_new_and_deprecated_named_routes + @set.expects(:add_named_route).with("new", "path", {:a => "b"}) + @set.expects(:add_deprecated_named_route).with("new", "old", "path", {:a => "b"}) + @mapper.deprecated_named_route("new", "old", "path", {:a => "b"}) + end + + def test_should_not_add_deprecated_named_route_if_both_are_the_same + @set.expects(:add_named_route).with("new", "path", {:a => "b"}) + @set.expects(:add_deprecated_named_route).with("new", "new", "path", {:a => "b"}).never + @mapper.deprecated_named_route("new", "new", "path", {:a => "b"}) + end +end + +class RouteSetDeprecatedRouteTest < Test::Unit::TestCase + def setup + @set = ActionController::Routing::RouteSet.new + end + + def test_should_add_deprecated_route + @set.expects(:add_named_route).with("old", "path", {:a => "b"}) + @set.add_deprecated_named_route("new", "old", "path", {:a => "b"}) + end + + def test_should_fire_deprecation_warning_on_access + @set.add_deprecated_named_route("new_outer_inner_path", "outer_new_inner_path", "/outers/:outer_id/inners/new", :controller => :inners) + ActiveSupport::Deprecation.expects(:warn) + @set.named_routes["outer_new_inner_path"] + end +end + end # uses_mocha class RouteBuilderTest < Test::Unit::TestCase @@ -1957,4 +1993,4 @@ class RoutingTest < Test::Unit::TestCase assert c.ancestors.include?(h) end -end +end \ No newline at end of file -- cgit v1.2.3