Permalink
Browse files

Removed deprecated RouteSet API, still many tests fail

  • Loading branch information...
drogus committed Aug 5, 2010
1 parent 91fec0d commit b3eb26a161acb23781e55fc6c37b948f160cd9b5
Showing with 567 additions and 606 deletions.
  1. +0 −1 actionpack/lib/action_dispatch/routing.rb
  2. +1 −6 actionpack/lib/action_dispatch/routing/mapper.rb
  3. +3 −9 actionpack/lib/action_dispatch/routing/route_set.rb
  4. +4 −14 actionpack/test/abstract_unit.rb
  5. +1 −1 actionpack/test/activerecord/active_record_store_test.rb
  6. +9 −9 actionpack/test/activerecord/polymorphic_routes_test.rb
  7. +8 −11 actionpack/test/controller/action_pack_assertions_test.rb
  8. +1 −1 actionpack/test/controller/base_test.rb
  9. +2 −2 actionpack/test/controller/caching_test.rb
  10. +1 −1 actionpack/test/controller/flash_test.rb
  11. +1 −1 actionpack/test/controller/integration_test.rb
  12. +1 −1 actionpack/test/controller/mime_responds_test.rb
  13. +3 −0 actionpack/test/controller/new_base/render_action_test.rb
  14. +1 −1 actionpack/test/controller/redirect_test.rb
  15. +1 −1 actionpack/test/controller/render_test.rb
  16. +2 −3 actionpack/test/controller/render_xml_test.rb
  17. +1 −1 actionpack/test/controller/rescue_test.rb
  18. +168 −172 actionpack/test/controller/resources_test.rb
  19. +327 −348 actionpack/test/controller/routing_test.rb
  20. +9 −4 actionpack/test/controller/test_test.rb
  21. +4 −4 actionpack/test/controller/url_for_test.rb
  22. +5 −0 actionpack/test/controller/url_rewriter_test.rb
  23. +1 −1 actionpack/test/controller/webservice_test.rb
  24. +1 −1 actionpack/test/dispatch/request/json_params_parsing_test.rb
  25. +1 −1 actionpack/test/dispatch/request/multipart_params_parsing_test.rb
  26. +1 −1 actionpack/test/dispatch/request/query_string_parsing_test.rb
  27. +1 −1 actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
  28. +1 −1 actionpack/test/dispatch/request/xml_params_parsing_test.rb
  29. +1 −1 actionpack/test/dispatch/session/cookie_store_test.rb
  30. +1 −1 actionpack/test/dispatch/session/mem_cache_store_test.rb
  31. +1 −1 actionpack/test/template/atom_feed_helper_test.rb
  32. +2 −2 actionpack/test/template/test_case_test.rb
  33. +1 −1 actionpack/test/template/test_test.rb
  34. +2 −3 actionpack/test/template/url_helper_test.rb
@@ -264,7 +264,6 @@ module ActionDispatch
# Target specific controllers by prefixing the command with <tt>CONTROLLER=x</tt>.
#
module Routing
- autoload :DeprecatedMapper, 'action_dispatch/routing/deprecated_mapper'
autoload :Mapper, 'action_dispatch/routing/mapper'
autoload :Route, 'action_dispatch/routing/route'
autoload :RouteSet, 'action_dispatch/routing/route_set'
@@ -443,11 +443,6 @@ def scope(*args)
options = args.extract_options!
options = options.dup
- if name_prefix = options.delete(:name_prefix)
- options[:as] ||= name_prefix
- ActiveSupport::Deprecation.warn ":name_prefix was deprecated in the new router syntax. Use :as instead.", caller
- end
-
options[:path] = args.first if args.first.is_a?(String)
recover = {}
@@ -770,7 +765,7 @@ def resources(*resources, &block)
end
resource_scope(Resource.new(resources.pop, options)) do
- yield if block_given?
+ instance_eval(&block) if block_given?
collection_scope do
get :index if parent_resource.actions.include?(:index)
@@ -1,7 +1,6 @@
require 'rack/mount'
require 'forwardable'
require 'active_support/core_ext/object/to_query'
-require 'action_dispatch/routing/deprecated_mapper'
module ActionDispatch
module Routing
@@ -211,7 +210,6 @@ def initialize(request_class = ActionDispatch::Request)
self.routes = []
self.named_routes = NamedRouteCollection.new
self.resources_path_names = self.class.default_resources_path_names.dup
- self.controller_namespaces = Set.new
self.default_url_options = {}
self.request_class = request_class
@@ -227,14 +225,10 @@ def draw(&block)
clear! unless @disable_clear_and_finalize
mapper = Mapper.new(self)
- if block.arity == 1
- mapper.instance_exec(DeprecatedMapper.new(self), &block)
+ if default_scope
+ mapper.with_default_scope(default_scope, &block)
else
- if default_scope
- mapper.with_default_scope(default_scope, &block)
- else
- mapper.instance_exec(&block)
- end
+ mapper.instance_exec(&block)
end
finalize! unless @disable_clear_and_finalize
@@ -49,14 +49,6 @@
module Rails
end
-# Monkey patch the old routes initialization to be silenced.
-class ActionDispatch::Routing::DeprecatedMapper
- def initialize_with_silencer(*args)
- ActiveSupport::Deprecation.silence { initialize_without_silencer(*args) }
- end
- alias_method_chain :initialize, :silencer
-end
-
ActiveSupport::Dependencies.hook!
# Show backtraces for deprecated behavior for quicker cleanup.
@@ -128,14 +120,12 @@ class TestCase
# Hold off drawing routes until all the possible controller classes
# have been loaded.
setup_once do
- SharedTestRoutes.draw do |map|
- # FIXME: match ':controller(/:action(/:id))'
- map.connect ':controller/:action/:id'
+ SharedTestRoutes.draw do
+ match ':controller(/:action)'
end
- ActionController::IntegrationTest.app.routes.draw do |map|
- # FIXME: match ':controller(/:action(/:id))'
- map.connect ':controller/:action/:id'
+ ActionController::IntegrationTest.app.routes.draw do
+ match ':controller(/:action)'
end
end
end
@@ -198,7 +198,7 @@ def test_allows_session_fixation
def with_test_route_set(options = {})
with_routing do |set|
- set.draw do |map|
+ set.draw do
match ':action', :to => 'active_record_store_test/test'
end
@@ -451,18 +451,18 @@ def with_namespaced_routes(name)
def with_test_routes(options = {})
with_routing do |set|
- set.draw do |map|
- map.resources :projects do |projects|
- projects.resources :tasks
- projects.resource :bid do |bid|
- bid.resources :tasks
+ set.draw do
+ resources :projects do
+ resources :tasks
+ resource :bid do
+ resources :tasks
end
end
- map.resources :taxes do |taxes|
- taxes.resources :faxes
- taxes.resource :bid
+ resources :taxes do
+ resources :faxes
+ resource :bid
end
- map.resources :series
+ resources :series
end
self.class.send(:include, @routes.url_helpers)
@@ -222,7 +222,7 @@ def test_post
# test the redirection to a named route
def test_assert_redirect_to_named_route
with_routing do |set|
- set.draw do |map|
+ set.draw do
match 'route_one', :to => 'action_pack_assertions#nothing', :as => :route_one
match ':controller/:action'
end
@@ -236,7 +236,7 @@ def test_assert_redirect_to_named_route
def test_assert_redirect_to_named_route_failure
with_routing do |set|
- set.draw do |map|
+ set.draw do
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'
@@ -258,10 +258,9 @@ def test_assert_redirect_to_nested_named_route
@controller = Admin::InnerModuleController.new
with_routing do |set|
- set.draw do |map|
+ set.draw do
match 'admin/inner_module', :to => 'admin/inner_module#index', :as => :admin_inner_module
- # match ':controller/:action'
- map.connect ':controller/:action/:id'
+ match ':controller/:action'
end
process :redirect_to_index
# redirection is <{"action"=>"index", "controller"=>"admin/admin/inner_module"}>
@@ -273,10 +272,9 @@ def test_assert_redirected_to_top_level_named_route_from_nested_controller
@controller = Admin::InnerModuleController.new
with_routing do |set|
- set.draw do |map|
+ set.draw do
match '/action_pack_assertions/:id', :to => 'action_pack_assertions#index', :as => :top_level
- # match ':controller/:action'
- map.connect ':controller/:action/:id'
+ match ':controller/:action'
end
process :redirect_to_top_level_named_route
# assert_redirected_to "http://test.host/action_pack_assertions/foo" would pass because of exact match early return
@@ -288,11 +286,10 @@ def test_assert_redirected_to_top_level_named_route_with_same_controller_name_in
@controller = Admin::InnerModuleController.new
with_routing do |set|
- set.draw do |map|
+ set.draw do
# this controller exists in the admin namespace as well which is the only difference from previous test
match '/user/:id', :to => 'user#index', :as => :top_level
- # match ':controller/:action'
- map.connect ':controller/:action/:id'
+ match ':controller/:action'
end
process :redirect_to_top_level_named_route
# assert_redirected_to top_level_url('foo') would pass because of exact match early return
@@ -294,7 +294,7 @@ def test_named_routes_with_path_without_doing_a_request_first
@controller.request = @request
with_routing do |set|
- set.draw do |map|
+ set.draw do
resources :things
end
@@ -76,7 +76,7 @@ def teardown
def test_page_caching_resources_saves_to_correct_path_with_extension_even_if_default_route
with_routing do |set|
- set.draw do |map|
+ set.draw do
match 'posts.:format', :to => 'posts#index', :as => :formatted_posts
match '/', :to => 'posts#index', :as => :main
end
@@ -452,7 +452,7 @@ def test_forbidden_is_not_cached
def test_xml_version_of_resource_is_treated_as_different_cache
with_routing do |set|
- set.draw do |map|
+ set.draw do
match ':controller(/:action(.:format))'
end
@@ -255,7 +255,7 @@ def get(path, parameters = nil, env = {})
def with_test_route_set
with_routing do |set|
- set.draw do |map|
+ set.draw do
match ':action', :to => FlashIntegrationTest::TestController
end
@@ -427,7 +427,7 @@ def with_test_route_set
include set.url_helpers
end
- set.draw do |map|
+ set.draw do
match ':action', :to => controller
get 'get/:action', :to => controller
end
@@ -876,7 +876,7 @@ def test_error_is_raised_if_no_respond_to_is_declared_and_respond_with_is_called
private
def with_test_route_set
with_routing do |set|
- set.draw do |map|
+ set.draw do
resources :customers
resources :quiz_stores do
resources :customers
@@ -83,6 +83,9 @@ class RenderActionTest < Rack::TestCase
end
class RenderLayoutTest < Rack::TestCase
+ def setup
+ end
+
describe "Both <controller_path>.html.erb and application.html.erb are missing"
test "rendering with layout => true" do
@@ -232,7 +232,7 @@ def test_redirect_to_back_with_no_referer
def test_redirect_to_record
with_routing do |set|
- set.draw do |map|
+ set.draw do
resources :workshops
match ':controller/:action'
end
@@ -1120,7 +1120,7 @@ def test_head_with_location_header
def test_head_with_location_object
with_routing do |set|
- set.draw do |map|
+ set.draw do
resources :customers
match ':controller/:action'
end
@@ -70,10 +70,9 @@ def test_rendering_xml_should_call_to_xml_with_extra_options
def test_rendering_with_object_location_should_set_header_with_url_for
with_routing do |set|
- set.draw do |map|
+ set.draw do
resources :customers
- # match ':controller/:action'
- map.connect ':controller/:action/:id'
+ match ':controller/:action'
end
get :render_with_object_location
@@ -371,7 +371,7 @@ def show_errors(exception)
private
def with_test_routing
with_routing do |set|
- set.draw do |map|
+ set.draw do
match 'foo', :to => ::RescueTest::TestController.action(:foo)
match 'invalid', :to => ::RescueTest::TestController.action(:invalid)
match 'b00m', :to => ::RescueTest::TestController.action(:b00m)
Oops, something went wrong.

0 comments on commit b3eb26a

Please sign in to comment.