Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8801

Show
Ignore:
Timestamp:
02/04/08 23:26:25 (5 months ago)
Author:
nzkoz
Message:

Ensure that assert_redirected_to to top-level named route from namespaced controller work. Closes #10812 [dasil003]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2-0-stable/actionpack/lib/action_controller/assertions/response_assertions.rb

    r8585 r8801  
    9696                if key == :actual && value['controller'].first != '/' && !value['controller'].include?('/') 
    9797                  new_controller_path = ActionController::Routing.controller_relative_to(value['controller'], @controller.class.controller_path) 
    98                   value['controller'] = new_controller_path if value['controller'] != new_controller_path && ActionController::Routing.possible_controllers.include?(new_controller_path) 
     98                  value['controller'] = new_controller_path if value['controller'] != new_controller_path && ActionController::Routing.possible_controllers.include?(new_controller_path) && @response.redirected_to.is_a?(Hash) 
    9999                end 
    100100                value['controller'] = value['controller'][1..-1] if value['controller'].first == '/' # strip leading hash 
  • branches/2-0-stable/actionpack/test/controller/action_pack_assertions_test.rb

    r8585 r8801  
    134134end 
    135135 
     136class UserController < ActionController::Base 
     137end 
     138 
    136139module Admin 
    137140  class InnerModuleController < ActionController::Base 
     
    171174  def setup 
    172175    ActionController::Routing::Routes.reload 
    173     ActionController::Routing.use_controllers!(%w(action_pack_assertions admin/inner_module content admin/user)) 
     176    ActionController::Routing.use_controllers!(%w(action_pack_assertions admin/inner_module user content admin/user)) 
    174177    @controller = ActionPackAssertionsController.new 
    175178    @request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new 
     
    265268    end 
    266269  end 
    267    
     270 
    268271  def test_assert_redirected_to_top_level_named_route_from_nested_controller 
    269272    with_routing do |set| 
     
    276279      # passes -> assert_redirected_to "http://test.host/action_pack_assertions/foo" 
    277280      assert_redirected_to "/action_pack_assertions/foo" 
     281    end 
     282  end 
     283 
     284 
     285  def test_assert_redirected_to_top_level_named_route_with_same_controller_name_in_both_namespaces 
     286    with_routing do |set| 
     287      set.draw do |map| 
     288        # this controller exists in the admin namespace as well which is the only difference from previous test 
     289        map.top_level '/user/:id', :controller => 'user', :action => 'index' 
     290        map.connect   ':controller/:action/:id' 
     291      end 
     292      @controller = Admin::InnerModuleController.new 
     293      process :redirect_to_top_level_named_route 
     294      assert_redirected_to "/user/foo" 
    278295    end 
    279296  end