diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-09-06 23:21:04 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-09-06 23:21:04 -0500 |
commit | 1a0f822037c408a392ffa7b6e1ecbe5951ab48db (patch) | |
tree | ba627f84c14a671e990d56235d9f89d0773a5d37 | |
parent | 314e18aba24709310a60b5fe2b1930fe1ef3ed51 (diff) | |
download | rails-1a0f822037c408a392ffa7b6e1ecbe5951ab48db.tar.gz rails-1a0f822037c408a392ffa7b6e1ecbe5951ab48db.tar.bz2 rails-1a0f822037c408a392ffa7b6e1ecbe5951ab48db.zip |
Use draw/connect mapper api instead of directly using add_named_route
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 17f5e86a56..1aabf71cad 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -232,14 +232,18 @@ class LegacyRouteSetTests < Test::Unit::TestCase end def test_basic_named_route - rs.add_named_route :home, '', :controller => 'content', :action => 'list' + rs.draw do |map| + map.home '', :controller => 'content', :action => 'list' + end x = setup_for_named_route assert_equal("http://test.host/", x.send(:home_url)) end def test_basic_named_route_with_relative_url_root - rs.add_named_route :home, '', :controller => 'content', :action => 'list' + rs.draw do |map| + map.home '', :controller => 'content', :action => 'list' + end x = setup_for_named_route ActionController::Base.relative_url_root = "/foo" assert_equal("http://test.host/foo/", @@ -249,14 +253,18 @@ class LegacyRouteSetTests < Test::Unit::TestCase end def test_named_route_with_option - rs.add_named_route :page, 'page/:title', :controller => 'content', :action => 'show_page' + rs.draw do |map| + map.page 'page/:title', :controller => 'content', :action => 'show_page' + end x = setup_for_named_route assert_equal("http://test.host/page/new%20stuff", x.send(:page_url, :title => 'new stuff')) end def test_named_route_with_default - rs.add_named_route :page, 'page/:title', :controller => 'content', :action => 'show_page', :title => 'AboutPage' + rs.draw do |map| + map.page 'page/:title', :controller => 'content', :action => 'show_page', :title => 'AboutPage' + end x = setup_for_named_route assert_equal("http://test.host/page/AboutRails", x.send(:page_url, :title => "AboutRails")) @@ -264,36 +272,46 @@ class LegacyRouteSetTests < Test::Unit::TestCase end def test_named_route_with_name_prefix - rs.add_named_route :page, 'page', :controller => 'content', :action => 'show_page', :name_prefix => 'my_' + rs.draw do |map| + map.page 'page', :controller => 'content', :action => 'show_page', :name_prefix => 'my_' + end x = setup_for_named_route assert_equal("http://test.host/page", x.send(:my_page_url)) end def test_named_route_with_path_prefix - rs.add_named_route :page, 'page', :controller => 'content', :action => 'show_page', :path_prefix => 'my' + rs.draw do |map| + map.page 'page', :controller => 'content', :action => 'show_page', :path_prefix => 'my' + end x = setup_for_named_route assert_equal("http://test.host/my/page", x.send(:page_url)) end def test_named_route_with_blank_path_prefix - rs.add_named_route :page, 'page', :controller => 'content', :action => 'show_page', :path_prefix => '' + rs.draw do |map| + map.page 'page', :controller => 'content', :action => 'show_page', :path_prefix => '' + end x = setup_for_named_route assert_equal("http://test.host/page", x.send(:page_url)) end def test_named_route_with_nested_controller - rs.add_named_route :users, 'admin/user', :controller => 'admin/user', :action => 'index' + rs.draw do |map| + map.users 'admin/user', :controller => 'admin/user', :action => 'index' + end x = setup_for_named_route assert_equal("http://test.host/admin/user", x.send(:users_url)) end def test_optimised_named_route_call_never_uses_url_for - rs.add_named_route :users, 'admin/user', :controller => '/admin/user', :action => 'index' - rs.add_named_route :user, 'admin/user/:id', :controller=>'/admin/user', :action=>'show' + rs.draw do |map| + map.users 'admin/user', :controller => '/admin/user', :action => 'index' + map.user 'admin/user/:id', :controller=>'/admin/user', :action=>'show' + end x = setup_for_named_route x.expects(:url_for).never x.send(:users_url) @@ -303,7 +321,9 @@ class LegacyRouteSetTests < Test::Unit::TestCase end def test_optimised_named_route_with_host - rs.add_named_route :pages, 'pages', :controller => 'content', :action => 'show_page', :host => 'foo.com' + rs.draw do |map| + map.pages 'pages', :controller => 'content', :action => 'show_page', :host => 'foo.com' + end x = setup_for_named_route x.expects(:url_for).with(:host => 'foo.com', :only_path => false, :controller => 'content', :action => 'show_page', :use_route => :pages).once x.send(:pages_url) @@ -378,7 +398,9 @@ class LegacyRouteSetTests < Test::Unit::TestCase end def test_paths_slashes_unescaped_with_ordered_parameters - rs.add_named_route :path, '/file/*path', :controller => 'content' + rs.draw do |map| + map.path '/file/*path', :controller => 'content' + end # No / to %2F in URI, only for query params. x = setup_for_named_route |