aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/routing_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/controller/routing_test.rb')
-rw-r--r--actionpack/test/controller/routing_test.rb38
1 files changed, 37 insertions, 1 deletions
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