diff options
author | rick <technoweenie@gmail.com> | 2008-08-26 11:53:33 -0700 |
---|---|---|
committer | rick <technoweenie@gmail.com> | 2008-08-26 11:53:33 -0700 |
commit | 0aef9d1a2651fa0acd2adcd2de308eeb0ec8cdd2 (patch) | |
tree | 1a782151632dd80c8a18c3960536bdf8643debe3 /actionpack/test/controller/redirect_test.rb | |
parent | 0a6d75dedd79407376aae1f01302164dfd3e44b6 (diff) | |
parent | 229eedfda87a7706dbb5e3e51af8707b3adae375 (diff) | |
download | rails-0aef9d1a2651fa0acd2adcd2de308eeb0ec8cdd2.tar.gz rails-0aef9d1a2651fa0acd2adcd2de308eeb0ec8cdd2.tar.bz2 rails-0aef9d1a2651fa0acd2adcd2de308eeb0ec8cdd2.zip |
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'actionpack/test/controller/redirect_test.rb')
-rw-r--r--[-rwxr-xr-x] | actionpack/test/controller/redirect_test.rb | 109 |
1 files changed, 54 insertions, 55 deletions
diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb index 28da5c6163..2f8bf7b6ee 100755..100644 --- a/actionpack/test/controller/redirect_test.rb +++ b/actionpack/test/controller/redirect_test.rb @@ -9,11 +9,11 @@ class Workshop def initialize(id, new_record) @id, @new_record = id, new_record end - + def new_record? @new_record end - + def to_s id.to_s end @@ -24,32 +24,32 @@ class RedirectController < ActionController::Base redirect_to :action => "hello_world" end - def redirect_with_status + def redirect_with_status redirect_to({:action => "hello_world", :status => 301}) - end + end def redirect_with_status_hash redirect_to({:action => "hello_world"}, {:status => 301}) - end + end - def url_redirect_with_status + def url_redirect_with_status redirect_to("http://www.example.com", :status => :moved_permanently) - end - - def url_redirect_with_status_hash + end + + def url_redirect_with_status_hash redirect_to("http://www.example.com", {:status => 301}) - end + end - def relative_url_redirect_with_status + def relative_url_redirect_with_status redirect_to("/things/stuff", :status => :found) - end - + end + def relative_url_redirect_with_status_hash redirect_to("/things/stuff", {:status => 301}) - end - - def redirect_to_back_with_status - redirect_to :back, :status => 307 + end + + def redirect_to_back_with_status + redirect_to :back, :status => 307 end def host_redirect @@ -90,9 +90,9 @@ class RedirectController < ActionController::Base end def rescue_errors(e) raise e end - + def rescue_action(e) raise end - + protected def dashbord_url(id, message) url_for :action => "dashboard", :params => { "id" => id, "message" => message } @@ -118,48 +118,48 @@ class RedirectTest < Test::Unit::TestCase assert_equal "http://test.host/redirect/hello_world", redirect_to_url end - def test_redirect_with_status - get :redirect_with_status - assert_response 301 - assert_equal "http://test.host/redirect/hello_world", redirect_to_url - end + def test_redirect_with_status + get :redirect_with_status + assert_response 301 + assert_equal "http://test.host/redirect/hello_world", redirect_to_url + end - def test_redirect_with_status_hash + def test_redirect_with_status_hash get :redirect_with_status_hash - assert_response 301 - assert_equal "http://test.host/redirect/hello_world", redirect_to_url + assert_response 301 + assert_equal "http://test.host/redirect/hello_world", redirect_to_url + end + + def test_url_redirect_with_status + get :url_redirect_with_status + assert_response 301 + assert_equal "http://www.example.com", redirect_to_url end - - def test_url_redirect_with_status - get :url_redirect_with_status - assert_response 301 - assert_equal "http://www.example.com", redirect_to_url - end def test_url_redirect_with_status_hash get :url_redirect_with_status_hash - assert_response 301 - assert_equal "http://www.example.com", redirect_to_url - end + assert_response 301 + assert_equal "http://www.example.com", redirect_to_url + end - - def test_relative_url_redirect_with_status - get :relative_url_redirect_with_status + + def test_relative_url_redirect_with_status + get :relative_url_redirect_with_status assert_response 302 - assert_equal "http://test.host/things/stuff", redirect_to_url - end - + assert_equal "http://test.host/things/stuff", redirect_to_url + end + def test_relative_url_redirect_with_status_hash get :relative_url_redirect_with_status_hash - assert_response 301 - assert_equal "http://test.host/things/stuff", redirect_to_url - end - - def test_redirect_to_back_with_status - @request.env["HTTP_REFERER"] = "http://www.example.com/coming/from" - get :redirect_to_back_with_status - assert_response 307 - assert_equal "http://www.example.com/coming/from", redirect_to_url + assert_response 301 + assert_equal "http://test.host/things/stuff", redirect_to_url + end + + def test_redirect_to_back_with_status + @request.env["HTTP_REFERER"] = "http://www.example.com/coming/from" + get :redirect_to_back_with_status + assert_response 307 + assert_equal "http://www.example.com/coming/from", redirect_to_url end def test_simple_redirect_using_options @@ -204,20 +204,20 @@ class RedirectTest < Test::Unit::TestCase assert_response :redirect assert_equal "http://www.example.com/coming/from", redirect_to_url end - + def test_redirect_to_back_with_no_referer assert_raises(ActionController::RedirectBackError) { @request.env["HTTP_REFERER"] = nil get :redirect_to_back } end - + def test_redirect_to_record ActionController::Routing::Routes.draw do |map| map.resources :workshops map.connect ':controller/:action/:id' end - + get :redirect_to_existing_record assert_equal "http://test.host/workshops/5", redirect_to_url assert_redirected_to Workshop.new(5, false) @@ -237,7 +237,6 @@ class RedirectTest < Test::Unit::TestCase get :redirect_to_nil end end - end module ModuleTest |