We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 16822ea commit 9b24690Copy full SHA for 9b24690
lib/http_router/route.rb
@@ -26,7 +26,7 @@ def matches_with(var_name)
26
27
def name=(name)
28
@name = name
29
- router.named_routes[name] << self
+ router.named_routes[name] << self if router
30
end
31
32
-end
+end
test/test_misc.rb
@@ -118,4 +118,10 @@ def test_to_s_and_inspect
118
assert router.inspect.match(/^#<HttpRouter:0x[0-9a-f-]+ number of routes \(3\) ignore_trailing_slash\? \(true\) redirect_trailing_slash\? \(false\)>/)
119
assert router.inspect.match(/Path: "\/test" for route unnamed route to :test3/)
120
121
+
122
+ def test_naming_route_with_no_router
123
+ route = HttpRouter::Route.new
124
+ route.name = 'named_route'
125
+ assert_equal 'named_route', route.name
126
+ end
127
0 commit comments