mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #20191 from juggernaut-/patch-1
Added ActionDispatch::Journey::Routes#empty?
This commit is contained in:
commit
7145986e88
3 changed files with 20 additions and 0 deletions
|
@ -16,6 +16,10 @@ module ActionDispatch
|
|||
@simulator = nil
|
||||
end
|
||||
|
||||
def empty?
|
||||
routes.empty?
|
||||
end
|
||||
|
||||
def length
|
||||
routes.length
|
||||
end
|
||||
|
|
|
@ -17,6 +17,16 @@ module ActionDispatch
|
|||
@set = RouteSet.new
|
||||
end
|
||||
|
||||
test "not being empty when route is added" do
|
||||
assert empty?
|
||||
|
||||
draw do
|
||||
get 'foo', to: SimpleApp.new('foo#index')
|
||||
end
|
||||
|
||||
refute empty?
|
||||
end
|
||||
|
||||
test "url helpers are added when route is added" do
|
||||
draw do
|
||||
get 'foo', to: SimpleApp.new('foo#index')
|
||||
|
@ -136,6 +146,10 @@ module ActionDispatch
|
|||
def url_helpers
|
||||
@set.url_helpers
|
||||
end
|
||||
|
||||
def empty?
|
||||
@set.empty?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,9 +14,11 @@ module ActionDispatch
|
|||
requirements = { :hello => /world/ }
|
||||
|
||||
routes.add_route nil, path, requirements, {:id => nil}, {}
|
||||
refute routes.empty?
|
||||
assert_equal 1, routes.length
|
||||
|
||||
routes.clear
|
||||
assert routes.empty?
|
||||
assert_equal 0, routes.length
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue