Don't assume a router in Route#name=.

This commit is contained in:
Jimmy Cuadra 2014-08-01 04:07:40 -07:00
parent 16822eae88
commit 9b24690f1f
2 changed files with 8 additions and 2 deletions

View File

@ -26,7 +26,7 @@ class HttpRouter
def name=(name)
@name = name
router.named_routes[name] << self
router.named_routes[name] << self if router
end
end
end
end

View File

@ -118,4 +118,10 @@ class TestMisc < MiniTest::Unit::TestCase
assert router.inspect.match(/^#<HttpRouter:0x[0-9a-f-]+ number of routes \(3\) ignore_trailing_slash\? \(true\) redirect_trailing_slash\? \(false\)>/)
assert router.inspect.match(/Path: "\/test" for route unnamed route to :test3/)
end
def test_naming_route_with_no_router
route = HttpRouter::Route.new
route.name = 'named_route'
assert_equal 'named_route', route.name
end
end