This repository has been archived by the owner on Sep 13, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c0be4ca
commit e172eaa
Showing
4 changed files
with
43 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ def setup | |
|
||
def test_generate_id | ||
path = Path::Pattern.new '/:controller(/:action)' | ||
@router.add_route nil, {:path_info => path}, {}, nil | ||
@router.add_route nil, {:path_info => path}, {}, {} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
chancancode
Member
|
||
|
||
path, params = @router.generate( | ||
:path_info, nil, {:id=>1, :controller=>"tasks", :action=>"show"}, {}) | ||
|
@@ -18,7 +18,7 @@ def test_generate_id | |
|
||
def test_generate_extra_params | ||
path = Path::Pattern.new '/:controller(/:action)' | ||
@router.add_route nil, {:path_info => path}, {}, nil | ||
@router.add_route nil, {:path_info => path}, {}, {} | ||
|
||
path, params = @router.generate(:path_info, | ||
nil, { :id => 1, | ||
|
@@ -32,7 +32,7 @@ def test_generate_extra_params | |
|
||
def test_generate_with_name | ||
path = Path::Pattern.new '/:controller(/:action)' | ||
@router.add_route nil, {:path_info => path}, {}, nil | ||
@router.add_route nil, {:path_info => path}, {}, {} | ||
|
||
path, params = @router.generate(:path_info, | ||
"tasks", | ||
|
@@ -47,7 +47,7 @@ def test_extras_are_removed_when_formatting | |
@router.add_route nil, { :path_info => path }, { | ||
:controller => 'paths', | ||
:action => 'show' | ||
}, nil | ||
}, {} | ||
path = @router.generate(nil, nil, { | ||
:controller =>"pages", | ||
:id =>20, | ||
|
@@ -64,7 +64,7 @@ def test_extras_are_removed_when_formatting | |
define_method("test_recognize_#{expected.keys.map(&:to_s).join('_')}") do | ||
path = Path::Pattern.new "/:controller(/:action(/:id))" | ||
app = Object.new | ||
route = @router.add_route(app, { :path_info => path }, {}, nil) | ||
route = @router.add_route(app, { :path_info => path }, {}, {}) | ||
|
||
env = rails_env 'PATH_INFO' => request_path | ||
called = false | ||
|
@@ -79,6 +79,23 @@ def test_extras_are_removed_when_formatting | |
end | ||
end | ||
|
||
def test_recognize_literal | ||
path = Path::Pattern.new "/books(/:action(.:format))" | ||
app = Object.new | ||
route = @router.add_route(app, { :path_info => path }, {:controller => 'books'}) | ||
|
||
env = rails_env 'PATH_INFO' => '/books/list.rss' | ||
expected = { :controller => 'books', :action => 'list', :format => 'rss' } | ||
called = false | ||
@router.recognize(env) do |r, _, params| | ||
assert_equal route, r | ||
assert_equal(expected, params) | ||
called = true | ||
end | ||
|
||
assert called | ||
end | ||
|
||
private | ||
|
||
RailsEnv = Struct.new(:env) | ||
|
@tenderlove sorry for digging this up, but I came across this while working on rails#17725... do you remember why we are passing
{}
as the route name everywhere?