Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ActionDispatch::Journey::Routes#empty? #20191

Merged
merged 2 commits into from
May 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions actionpack/lib/action_dispatch/journey/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ def initialize
@simulator = nil
end

def empty?
routes.empty?
end

def length
routes.length
end
Expand Down
14 changes: 14 additions & 0 deletions actionpack/test/dispatch/routing/route_set_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ def call(env)
@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')
Expand Down Expand Up @@ -136,6 +146,10 @@ def draw(&block)
def url_helpers
@set.url_helpers
end

def empty?
@set.empty?
end
end
end
end
2 changes: 2 additions & 0 deletions actionpack/test/journey/routes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ def test_clear
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

Expand Down