aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-05-12 21:12:31 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-05-12 21:12:31 +0000
commitc769ad85336713b7e5bdadd57d92a007783f8208 (patch)
treeecd60b6abc044f8eb80558a631edcf7f8662c406 /actionpack/test/controller
parent2ca6f57f85fe06932f64685bea2687fec7d6c3d3 (diff)
downloadrails-c769ad85336713b7e5bdadd57d92a007783f8208.tar.gz
rails-c769ad85336713b7e5bdadd57d92a007783f8208.tar.bz2
rails-c769ad85336713b7e5bdadd57d92a007783f8208.zip
Removed deprecated parameters_for_method_reference concept (legacy from before named routes) [DHH] Added record identification with polymorphic routes for ActionController::Base#url_for and ActionView::Base#url_for [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6729 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller')
-rwxr-xr-xactionpack/test/controller/redirect_test.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb
index df037ec28d..c7e4c19a0a 100755
--- a/actionpack/test/controller/redirect_test.rb
+++ b/actionpack/test/controller/redirect_test.rb
@@ -1,5 +1,24 @@
require File.dirname(__FILE__) + '/../abstract_unit'
+class WorkshopsController < ActionController::Base
+end
+
+class Workshop
+ attr_accessor :id, :new_record
+
+ 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
+end
+
class RedirectController < ActionController::Base
def simple_redirect
redirect_to :action => "hello_world"
@@ -22,6 +41,14 @@ class RedirectController < ActionController::Base
redirect_to :back
end
+ def redirect_to_existing_record
+ redirect_to Workshop.new(5, false)
+ end
+
+ def redirect_to_new_record
+ redirect_to Workshop.new(5, true)
+ end
+
def rescue_errors(e) raise e end
def rescue_action(e) raise end
@@ -97,6 +124,19 @@ class RedirectTest < Test::Unit::TestCase
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
+
+ get :redirect_to_new_record
+ assert_equal "http://test.host/workshops", redirect_to_url
+ end
end
module ModuleTest