From 2be5e088d27f17cd7210cbfd227aff2e5be6b800 Mon Sep 17 00:00:00 2001
From: Joshua Peek <josh@joshpeek.com>
Date: Tue, 8 Dec 2009 16:52:26 -0600
Subject: Use new routing dsl in tests

---
 actionpack/test/abstract_unit.rb                   |  2 +-
 .../test/activerecord/active_record_store_test.rb  |  2 +-
 .../test/controller/action_pack_assertions_test.rb | 22 ++++++++--------
 actionpack/test/controller/base_test.rb            |  6 ++---
 actionpack/test/controller/mime_responds_test.rb   |  8 +++---
 actionpack/test/controller/redirect_test.rb        |  4 +--
 actionpack/test/controller/render_test.rb          | 30 +++++++++++-----------
 actionpack/test/controller/render_xml_test.rb      |  4 +--
 actionpack/test/controller/test_test.rb            | 11 --------
 actionpack/test/controller/url_rewriter_test.rb    |  4 +--
 actionpack/test/controller/webservice_test.rb      |  4 +--
 .../request/multipart_params_parsing_test.rb       |  2 +-
 actionpack/test/template/atom_feed_helper_test.rb  | 12 ++++-----
 actionpack/test/template/test_case_test.rb         |  4 +--
 actionpack/test/template/url_helper_test.rb        |  8 +++---
 15 files changed, 56 insertions(+), 67 deletions(-)

diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index 9d055da4b9..eab9f8b83d 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -83,7 +83,7 @@ class ActiveSupport::TestCase
   # have been loaded.
   setup_once do
     ActionController::Routing::Routes.draw do |map|
-      map.connect ':controller/:action/:id'
+      match ':controller(/:action(/:id))'
     end
   end
 end
diff --git a/actionpack/test/activerecord/active_record_store_test.rb b/actionpack/test/activerecord/active_record_store_test.rb
index c6c079f88c..61bee1b66c 100644
--- a/actionpack/test/activerecord/active_record_store_test.rb
+++ b/actionpack/test/activerecord/active_record_store_test.rb
@@ -155,7 +155,7 @@ class ActiveRecordStoreTest < ActionController::IntegrationTest
     def with_test_route_set(options = {})
       with_routing do |set|
         set.draw do |map|
-          map.connect "/:action", :controller => "active_record_store_test/test"
+          match ':action', :to => 'active_record_store_test/test'
         end
         @app = ActiveRecord::SessionStore.new(set, options.reverse_merge(:key => '_session_id'))
         yield
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb
index 901cb940ea..d54be9bdc0 100644
--- a/actionpack/test/controller/action_pack_assertions_test.rb
+++ b/actionpack/test/controller/action_pack_assertions_test.rb
@@ -221,8 +221,8 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase
   def test_assert_redirect_to_named_route
     with_routing do |set|
       set.draw do |map|
-        map.route_one 'route_one', :controller => 'action_pack_assertions', :action => 'nothing'
-        map.connect   ':controller/:action/:id'
+        match 'route_one', :to => 'action_pack_assertions#nothing', :as => :route_one
+        match ':controller/:action'
       end
       set.install_helpers
 
@@ -235,9 +235,9 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase
   def test_assert_redirect_to_named_route_failure
     with_routing do |set|
       set.draw do |map|
-        map.route_one 'route_one', :controller => 'action_pack_assertions', :action => 'nothing', :id => 'one'
-        map.route_two 'route_two', :controller => 'action_pack_assertions', :action => 'nothing', :id => 'two'
-        map.connect   ':controller/:action/:id'
+        match 'route_one', :to => 'action_pack_assertions#nothing', :as => :route_one
+        match 'route_two', :to => 'action_pack_assertions#nothing', :id => 'two', :as => :route_two
+        match ':controller/:action'
       end
       process :redirect_to_named_route
       assert_raise(ActiveSupport::TestCase::Assertion) do
@@ -255,8 +255,8 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase
   def test_assert_redirect_to_nested_named_route
     with_routing do |set|
       set.draw do |map|
-        map.admin_inner_module 'admin/inner_module', :controller => 'admin/inner_module', :action => 'index'
-        map.connect            ':controller/:action/:id'
+        match 'admin/inner_module', :to => 'admin/inner_module#index', :as => :admin_inner_module
+        match ':controller/:action'
       end
       @controller = Admin::InnerModuleController.new
       process :redirect_to_index
@@ -268,8 +268,8 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase
   def test_assert_redirected_to_top_level_named_route_from_nested_controller
     with_routing do |set|
       set.draw do |map|
-        map.top_level '/action_pack_assertions/:id', :controller => 'action_pack_assertions', :action => 'index'
-        map.connect   ':controller/:action/:id'
+        match '/action_pack_assertions/:id', :to => 'action_pack_assertions#index', :as => :top_level
+        match ':controller/:action'
       end
       @controller = Admin::InnerModuleController.new
       process :redirect_to_top_level_named_route
@@ -282,8 +282,8 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase
     with_routing do |set|
       set.draw do |map|
         # this controller exists in the admin namespace as well which is the only difference from previous test
-        map.top_level '/user/:id', :controller => 'user', :action => 'index'
-        map.connect   ':controller/:action/:id'
+        match '/user/:id', :to => 'user#index', :as => :top_level
+        match ':controller/:action'
       end
       @controller = Admin::InnerModuleController.new
       process :redirect_to_top_level_named_route
diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb
index b57550a69a..8f8ada8d8c 100644
--- a/actionpack/test/controller/base_test.rb
+++ b/actionpack/test/controller/base_test.rb
@@ -179,8 +179,8 @@ class DefaultUrlOptionsTest < ActionController::TestCase
   def test_default_url_options_are_used_if_set
     with_routing do |set|
       set.draw do |map|
-        map.default_url_options 'default_url_options', :controller => 'default_url_options'
-        map.connect ':controller/:action/:id'
+        match 'default_url_options', :to => 'default_url_options#default_url_options_action', :as => :default_url_options
+        match ':controller/:action'
       end
 
       get :default_url_options_action # Make a dummy request so that the controller is initialized properly.
@@ -210,7 +210,7 @@ class EnsureNamedRoutesWorksTicket22BugTest < ActionController::TestCase
   def test_named_routes_still_work
     with_routing do |set|
       set.draw do |map|
-        map.resources :things
+        resources :things
       end
       EmptyController.send :include, ActionController::UrlWriter
 
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index c1fa74b8c8..dd1f2f3d3c 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -827,9 +827,11 @@ class RespondWithControllerTest < ActionController::TestCase
     def with_test_route_set
       with_routing do |set|
         set.draw do |map|
-          map.resources :customers
-          map.resources :quiz_stores, :has_many => :customers
-          map.connect ":controller/:action/:id"
+          resources :customers
+          resources :quiz_stores do
+            resources :customers
+          end
+          match ":controller/:action"
         end
         yield
       end
diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb
index ea278fd8f0..570ff4a41b 100644
--- a/actionpack/test/controller/redirect_test.rb
+++ b/actionpack/test/controller/redirect_test.rb
@@ -233,8 +233,8 @@ class RedirectTest < ActionController::TestCase
   def test_redirect_to_record
     with_routing do |set|
       set.draw do |map|
-        map.resources :workshops
-        map.connect ':controller/:action/:id'
+        resources :workshops
+        match ':controller/:action'
       end
 
       get :redirect_to_existing_record
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index cffa970011..f26b15d2e0 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -39,35 +39,35 @@ class TestController < ActionController::Base
       render :action => 'hello_world'
     end
   end
-  
+
   def conditional_hello_with_public_header
     if stale?(:last_modified => Time.now.utc.beginning_of_day, :etag => [:foo, 123], :public => true)
       render :action => 'hello_world'
     end
   end
-  
+
   def conditional_hello_with_public_header_and_expires_at
     expires_in 1.minute
     if stale?(:last_modified => Time.now.utc.beginning_of_day, :etag => [:foo, 123], :public => true)
       render :action => 'hello_world'
     end
   end
-  
+
   def conditional_hello_with_expires_in
     expires_in 60.1.seconds
     render :action => 'hello_world'
   end
-  
+
   def conditional_hello_with_expires_in_with_public
     expires_in 1.minute, :public => true
     render :action => 'hello_world'
   end
-  
+
   def conditional_hello_with_expires_in_with_public_with_more_keys
     expires_in 1.minute, :public => true, 'max-stale' => 5.hours
     render :action => 'hello_world'
   end
-  
+
   def conditional_hello_with_expires_in_with_public_with_more_keys_old_syntax
     expires_in 1.minute, :public => true, :private => nil, 'max-stale' => 5.hours
     render :action => 'hello_world'
@@ -272,7 +272,7 @@ class TestController < ActionController::Base
   def builder_layout_test
     render :action => "hello", :layout => "layouts/builder"
   end
-  
+
   # :move: test this in ActionView
   def builder_partial_test
     render :action => "hello_world_container"
@@ -1093,8 +1093,8 @@ class RenderTest < ActionController::TestCase
   def test_head_with_location_object
     with_routing do |set|
       set.draw do |map|
-        map.resources :customers
-        map.connect ':controller/:action/:id'
+        resources :customers
+        match ':controller/:action'
       end
 
       get :head_with_location_object
@@ -1306,22 +1306,22 @@ class ExpiresInRenderTest < ActionController::TestCase
   def setup
     @request.host = "www.nextangle.com"
   end
-  
+
   def test_expires_in_header
     get :conditional_hello_with_expires_in
     assert_equal "max-age=60, private", @response.headers["Cache-Control"]
   end
-  
+
   def test_expires_in_header_with_public
     get :conditional_hello_with_expires_in_with_public
     assert_equal "max-age=60, public", @response.headers["Cache-Control"]
   end
-  
+
   def test_expires_in_header_with_additional_headers
     get :conditional_hello_with_expires_in_with_public_with_more_keys
     assert_equal "max-age=60, public, max-stale=18000", @response.headers["Cache-Control"]
   end
-  
+
   def test_expires_in_old_syntax
     get :conditional_hello_with_expires_in_with_public_with_more_keys_old_syntax
     assert_equal "max-age=60, public, max-stale=18000", @response.headers["Cache-Control"]
@@ -1425,12 +1425,12 @@ class EtagRenderTest < ActionController::TestCase
     get :conditional_hello_with_bangs
     assert_response :not_modified
   end
-  
+
   def test_etag_with_public_true_should_set_header
     get :conditional_hello_with_public_header
     assert_equal "public", @response.headers['Cache-Control']
   end
-  
+
   def test_etag_with_public_true_should_set_header_and_retain_other_headers
     get :conditional_hello_with_public_header_and_expires_at
     assert_equal "max-age=60, public", @response.headers['Cache-Control']
diff --git a/actionpack/test/controller/render_xml_test.rb b/actionpack/test/controller/render_xml_test.rb
index 68a52c3e8c..b5b0d0b9d5 100644
--- a/actionpack/test/controller/render_xml_test.rb
+++ b/actionpack/test/controller/render_xml_test.rb
@@ -61,8 +61,8 @@ class RenderXmlTest < ActionController::TestCase
   def test_rendering_with_object_location_should_set_header_with_url_for
     with_routing do |set|
       set.draw do |map|
-        map.resources :customers
-        map.connect ':controller/:action/:id'
+        resources :customers
+        match ':controller/:action'
       end
 
       get :render_with_object_location
diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb
index 375878b755..52020922f2 100644
--- a/actionpack/test/controller/test_test.rb
+++ b/actionpack/test/controller/test_test.rb
@@ -628,17 +628,6 @@ XML
       assert_nothing_raised(NoMethodError) { @response.binary_content }
     end
   end
-
-  protected
-    def with_foo_routing
-      with_routing do |set|
-        set.draw do |map|
-          map.generate_url 'foo', :controller => 'test'
-          map.connect      ':controller/:action/:id'
-        end
-        yield set
-      end
-    end
 end
 
 class InferringClassNameTest < ActionController::TestCase
diff --git a/actionpack/test/controller/url_rewriter_test.rb b/actionpack/test/controller/url_rewriter_test.rb
index 3b14cbb2d8..ffc0353b00 100644
--- a/actionpack/test/controller/url_rewriter_test.rb
+++ b/actionpack/test/controller/url_rewriter_test.rb
@@ -247,7 +247,7 @@ class UrlWriterTests < ActionController::TestCase
 
     with_routing do |set|
       set.draw do |map|
-        map.home '/home/sweet/home/:user', :controller => 'home', :action => 'index'
+        match '/home/sweet/home/:user', :to => 'home#index', :as => :home
       end
 
       kls = Class.new { include ActionController::UrlWriter }
@@ -264,7 +264,7 @@ class UrlWriterTests < ActionController::TestCase
     with_routing do |set|
       set.draw do |map|
         match 'home/sweet/home/:user', :to => 'home#index', :as => :home
-        map.connect ':controller/:action/:id'
+        match ':controller/:action/:id'
       end
 
       # We need to create a new class in order to install the new named route.
diff --git a/actionpack/test/controller/webservice_test.rb b/actionpack/test/controller/webservice_test.rb
index 0514c098bf..5882a8cfa3 100644
--- a/actionpack/test/controller/webservice_test.rb
+++ b/actionpack/test/controller/webservice_test.rb
@@ -255,9 +255,7 @@ class WebServiceTest < ActionController::IntegrationTest
     def with_test_route_set
       with_routing do |set|
         set.draw do |map|
-          map.with_options :controller => "web_service_test/test" do |c|
-            c.connect "/", :action => "assign_parameters"
-          end
+          match '/', :to => 'web_service_test/test#assign_parameters'
         end
         yield
       end
diff --git a/actionpack/test/dispatch/request/multipart_params_parsing_test.rb b/actionpack/test/dispatch/request/multipart_params_parsing_test.rb
index 301080842e..40c5ac2d09 100644
--- a/actionpack/test/dispatch/request/multipart_params_parsing_test.rb
+++ b/actionpack/test/dispatch/request/multipart_params_parsing_test.rb
@@ -151,7 +151,7 @@ class MultipartParamsParsingTest < ActionController::IntegrationTest
     def with_test_routing
       with_routing do |set|
         set.draw do |map|
-          map.connect ':action', :controller => "multipart_params_parsing_test/test"
+          match ':action', :to => 'multipart_params_parsing_test/test'
         end
         yield
       end
diff --git a/actionpack/test/template/atom_feed_helper_test.rb b/actionpack/test/template/atom_feed_helper_test.rb
index 6a5fb0acff..347cb98303 100644
--- a/actionpack/test/template/atom_feed_helper_test.rb
+++ b/actionpack/test/template/atom_feed_helper_test.rb
@@ -187,10 +187,9 @@ class ScrollsController < ActionController::Base
   end
 
   protected
-
-  def rescue_action(e)
-    raise(e)
-  end
+    def rescue_action(e)
+      raise(e)
+    end
 end
 
 class AtomFeedTest < ActionController::TestCase
@@ -311,11 +310,12 @@ class AtomFeedTest < ActionController::TestCase
       assert_select "summary div p", :text => "after 2"
     end
   end
-private
+
+  private
     def with_restful_routing(resources)
       with_routing do |set|
         set.draw do |map|
-          map.resources(resources)
+          resources(resources)
         end
         yield
       end
diff --git a/actionpack/test/template/test_case_test.rb b/actionpack/test/template/test_case_test.rb
index 05a409d05a..9a448ce328 100644
--- a/actionpack/test/template/test_case_test.rb
+++ b/actionpack/test/template/test_case_test.rb
@@ -114,7 +114,7 @@ module ActionView
 
       test "is able to use named routes" do
         with_routing do |set|
-          set.draw { |map| map.resources :contents }
+          set.draw { |map| resources :contents }
           assert_equal 'http://test.host/contents/new', new_content_url
           assert_equal 'http://test.host/contents/1',   content_url(:id => 1)
         end
@@ -122,7 +122,7 @@ module ActionView
 
       test "named routes can be used from helper included in view" do
         with_routing do |set|
-          set.draw { |map| map.resources :contents }
+          set.draw { |map| resources :contents }
           _helpers.module_eval do
             def render_from_helper
               new_content_url
diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb
index 5c463a4f60..d4b58efe1e 100644
--- a/actionpack/test/template/url_helper_test.rb
+++ b/actionpack/test/template/url_helper_test.rb
@@ -451,7 +451,7 @@ class UrlHelperControllerTest < ActionController::TestCase
     def with_url_helper_routing
       with_routing do |set|
         set.draw do |map|
-          map.show_named_route 'url_helper_controller_test/url_helper/show_named_route', :controller => 'url_helper_controller_test/url_helper', :action => 'show_named_route'
+          match 'url_helper_controller_test/url_helper/show_named_route', :to => 'url_helper_controller_test/url_helper#show_named_route', :as => :show_named_route
         end
         yield
       end
@@ -505,7 +505,7 @@ class LinkToUnlessCurrentWithControllerTest < ActionController::TestCase
     def with_restful_routing
       with_routing do |set|
         set.draw do |map|
-          map.resources :tasks
+          resources :tasks
         end
         yield
       end
@@ -625,8 +625,8 @@ class PolymorphicControllerTest < ActionController::TestCase
     def with_restful_routing
       with_routing do |set|
         set.draw do |map|
-          map.resources :workshops do |w|
-            w.resources :sessions
+          resources :workshops do
+            resources :sessions
           end
         end
         yield
-- 
cgit v1.2.3