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

Changeset 1609

Show
Ignore:
Timestamp:
07/02/05 18:16:38 (3 years ago)
Author:
david
Message:

Added more tests on assert_redirected_to #1581 [Rick Olson]

Files:

Legend:

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

    r1606 r1609  
    1111    xml.cdata! "some text" # => <![CDATA[some text]]> 
    1212 
    13 * Added evaluation of <SCRIPT> blocks in content returned to Ajax calls #1577 [Thomas Fuchs/court3nay
     13* Added evaluation of <SCRIPT> blocks in content returned to Ajax calls #1577 [Thomas Fuchs/court3nay/Sean Treadway
    1414 
    1515* Directly generate paths with a leading slash instead of tacking it on later.  #1543 [Nicholas Seckar] 
  • trunk/actionpack/lib/action_controller/assertions.rb

    r1557 r1609  
    5757      # redirect_to(:controller => "weblog", :action => "show") and so on. 
    5858      def assert_redirected_to(options = {}, message=nil) 
    59         assert_redirect(message) 
     59        assert_response(:redirect, message) 
    6060 
    6161        if options.is_a?(String) 
    6262          msg = build_message(message, "expected a redirect to <?>, found one to <?>", options, @response.redirect_url) 
    63            
    6463          url_regexp = %r{^(\w+://.*?(/|$|\?))(.*)$} 
    6564          eurl, epath, url, path = [options, @response.redirect_url].collect do |url| 
  • trunk/actionpack/test/controller/redirect_test.rb

    r1251 r1609  
    1212  def host_redirect 
    1313    redirect_to :action => "other_host", :only_path => false, :host => 'other.test.host' 
     14  end 
     15 
     16  def module_redirect 
     17    redirect_to :controller => 'module_test/module_redirect', :action => "hello_world" 
    1418  end 
    1519 
     
    4347    assert_redirected_to :action => "other_host", :only_path => false, :host => 'other.test.host' 
    4448  end 
     49 
     50  def test_module_redirect 
     51    get :module_redirect 
     52    assert_redirect_url "http://test.host/module_test/module_redirect/hello_world" 
     53  end 
     54 
     55  def test_module_redirect_using_options 
     56    get :module_redirect 
     57    assert_redirected_to :controller => 'module_test/module_redirect', :action => 'hello_world' 
     58  end 
    4559end 
     60 
     61module ModuleTest 
     62  class ModuleRedirectController < ::RedirectController 
     63    def module_redirect 
     64      redirect_to :controller => '/redirect', :action => "hello_world" 
     65    end 
     66  end 
     67 
     68  class ModuleRedirectTest < Test::Unit::TestCase 
     69    def setup 
     70      @controller = ModuleRedirectController.new 
     71      @request    = ActionController::TestRequest.new 
     72      @response   = ActionController::TestResponse.new 
     73    end 
     74   
     75    def test_simple_redirect 
     76      get :simple_redirect 
     77      assert_redirect_url "http://test.host/module_test/module_redirect/hello_world" 
     78    end 
     79   
     80    def test_redirect_with_method_reference_and_parameters 
     81      get :method_redirect 
     82      assert_redirect_url "http://test.host/module_test/module_redirect/dashboard/1?message=hello" 
     83    end 
     84     
     85    def test_simple_redirect_using_options 
     86      get :host_redirect 
     87      assert_redirected_to :action => "other_host", :only_path => false, :host => 'other.test.host' 
     88    end 
     89 
     90    def test_module_redirect 
     91      get :module_redirect 
     92      assert_redirect_url "http://test.host/redirect/hello_world" 
     93    end 
     94 
     95    def test_module_redirect_using_options 
     96      get :module_redirect 
     97      assert_redirected_to :controller => 'redirect', :action => "hello_world" 
     98    end 
     99  end 
     100end