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

Changeset 4757

Show
Ignore:
Timestamp:
08/13/06 18:31:58 (2 years ago)
Author:
rick
Message:

Fix assert_redirected_to issue with named routes for module controllers. [Rick Olson]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r4756 r4757  
    11*SVN* 
     2 
     3* Fix assert_redirected_to issue with named routes for module controllers.  [Rick Olson] 
    24 
    35* Tweak RoutingError message to show option diffs, not just missing named route significant keys. [Rick Olson] 
  • trunk/actionpack/lib/action_controller/assertions.rb

    r4649 r4757  
    109109 
    110110              if value.respond_to?(:[]) && value['controller'] 
    111                 if key == :actual && value['controller'].first != '/' 
     111                if key == :actual && value['controller'].first != '/' && !value['controller'].include?('/') 
    112112                  value['controller'] = ActionController::Routing.controller_relative_to(value['controller'], @controller.class.controller_path)  
    113113                end 
     
    116116              url[key] = value 
    117117            end 
     118             
    118119 
    119120            @response_diff = url[:expected].diff(url[:actual]) if url[:actual] 
  • trunk/actionpack/test/controller/action_pack_assertions_test.rb

    r4715 r4757  
    125125module Admin 
    126126  class InnerModuleController < ActionController::Base 
     127    def index 
     128      render :nothing => true 
     129    end 
     130 
     131    def redirect_to_index 
     132      redirect_to admin_inner_module_path 
     133    end 
     134 
    127135    def redirect_to_absolute_controller 
    128136      redirect_to :controller => '/content' 
    129137    end 
     138 
    130139    def redirect_to_fellow_controller 
    131140      redirect_to :controller => 'user' 
     
    268277  end 
    269278 
     279  def test_assert_redirect_to_nested_named_route 
     280    with_routing do |set| 
     281      set.draw do |map| 
     282        map.admin_inner_module 'admin/inner_module', :controller => 'admin/inner_module', :action => 'index' 
     283        map.connect            ':controller/:action/:id' 
     284      end 
     285      @controller = Admin::InnerModuleController.new 
     286      process :redirect_to_index 
     287      # redirection is <{"action"=>"index", "controller"=>"admin/admin/inner_module"}> 
     288      assert_redirected_to admin_inner_module_path 
     289    end 
     290  end 
     291 
    270292  # test the flash-based assertions with something is in the flash 
    271293  def test_flash_assertions_full 
  • trunk/actionpack/test/controller/routing_test.rb

    r4677 r4757  
    133133                 x.send(:page_url, :title => "AboutRails")) 
    134134 
     135  end 
     136 
     137  def test_named_route_with_nested_controller 
     138    rs.add_named_route :users, 'admin/user', :controller => '/admin/user', :action => 'index' 
     139    x = setup_for_named_route.new 
     140    assert_equal({:controller => '/admin/user', :action => 'index', :use_route => :users}, 
     141                 x.send(:users_url)) 
    135142  end 
    136143 
     
    11781185      map.index '/people', :controller => 'people', :action => 'index' 
    11791186      map.multi '/people/go/:foo/:bar/joe/:id', :controller => 'people', :action => 'multi' 
     1187      map.users '/admin/users', :controller => 'admin/users', :action => 'index' 
    11801188    end 
    11811189 
     
    12101218    assert_equal "http://named.route.test/people", controller.send(:index_url) 
    12111219    assert_equal "/people", controller.send(:index_path) 
     1220 
     1221    assert_equal "http://named.route.test/admin/users", controller.send(:users_url) 
     1222    assert_equal '/admin/users', controller.send(:users_path) 
     1223    assert_equal '/admin/users', set.generate(controller.send(:hash_for_users_url), {:controller => 'users', :action => 'index'}) 
    12121224  end 
    12131225