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

Correct route requirements by overriding defaultls #18392

Merged
merged 1 commit into from
Apr 27, 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
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/journey/route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def ast

def requirements # :nodoc:
# needed for rails `rake routes`
path.requirements.merge(@defaults).delete_if { |_,v|
@defaults.merge(path.requirements).delete_if { |_,v|
/.+?/ == v
}
end
Expand Down
8 changes: 8 additions & 0 deletions actionpack/test/journey/route_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ def test_route_adds_itself_as_memo
end
end

def test_path_requirements_override_defaults
strexp = Router::Strexp.build(':name', { name: /love/ }, ['/'])
path = Path::Pattern.new strexp
defaults = { name: 'tender' }
route = Route.new('name', nil, path, nil, defaults)
assert_equal /love/, route.requirements[:name]
end

def test_ip_address
path = Path::Pattern.from_string '/messages/:id(.:format)'
route = Route.new("name", nil, path, {:ip => '192.168.1.1'},
Expand Down