1
0
Fork 0
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:
Rafael Mendonça França 2015-05-18 19:27:59 -03:00
commit 7145986e88
3 changed files with 20 additions and 0 deletions

View file

@ -16,6 +16,10 @@ module ActionDispatch
@simulator = nil
end
def empty?
routes.empty?
end
def length
routes.length
end

View file

@ -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

View file

@ -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