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

Changeset 1533

Show
Ignore:
Timestamp:
06/27/05 05:36:03 (3 years ago)
Author:
david
Message:

Fixed assert_redirected_to to handle absolute controller paths properly #1472 [Rick Olson/Nicholas Seckar]

Files:

Legend:

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

    r1532 r1533  
    11*SVN* 
     2 
     3* Fixed assert_redirected_to to handle absolute controller paths properly #1472 [Rick Olson/Nicholas Seckar] 
    24 
    35* Added event-based observations when frequency is not set on observe_field/form #1474 [flash@vanklinkenbergsoftware.nl] 
  • trunk/actionpack/lib/action_controller/assertions.rb

    r1517 r1533  
    7979              @response.redirected_to == options 
    8080            else 
    81               options.keys.all? do |k|  
    82                 options[k] == (@response.redirected_to[k].respond_to?(:to_param) ? @response.redirected_to[k].to_param : @response.redirected_to[k] unless @response.redirected_to[k].nil?) 
     81              options.keys.all? do |k| 
     82                if k == :controller then options[k] == ActionController::Routing.controller_relative_to(@response.redirected_to[k], @controller.class.controller_path) 
     83                else options[k] == (@response.redirected_to[k].respond_to?(:to_param) ? @response.redirected_to[k].to_param : @response.redirected_to[k] unless @response.redirected_to[k].nil?) 
     84                end 
    8385              end 
    8486            end 
  • trunk/actionpack/test/controller/action_pack_assertions_test.rb

    r1527 r1533  
    8080  # 911 
    8181  def rescue_action(e) raise; end 
    82      
     82end 
     83 
     84module Admin 
     85  class InnerModuleController < ActionController::Base 
     86    def redirect_to_absolute_controller 
     87      redirect_to :controller => '/content' 
     88    end 
     89    def redirect_to_fellow_controller 
     90      redirect_to :controller => 'user' 
     91    end 
     92  end 
    8393end 
    8494 
     
    393403    assert_redirected_to 'http://test.host/some/path' 
    394404  end 
     405 
     406  def test_redirected_to_with_nested_controller 
     407    @controller = Admin::InnerModuleController.new 
     408    get :redirect_to_absolute_controller 
     409    assert_redirected_to :controller => 'content' 
     410     
     411    get :redirect_to_fellow_controller 
     412    assert_redirected_to :controller => 'admin/user' 
     413  end 
    395414end 
    396415 
     
    405424  end 
    406425  def test_rendering_xml_respects_content_type 
    407          @response.headers['Content-Type'] = 'application/pdf' 
    408          process :hello_xml_world 
    409          assert_equal('application/pdf', @controller.headers['Content-Type']) 
     426    @response.headers['Content-Type'] = 'application/pdf' 
     427    process :hello_xml_world 
     428    assert_equal('application/pdf', @controller.headers['Content-Type']) 
    410429  end 
    411430end