From c769ad85336713b7e5bdadd57d92a007783f8208 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 12 May 2007 21:12:31 +0000 Subject: 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 --- actionpack/test/controller/redirect_test.rb | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'actionpack/test/controller') 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 -- cgit v1.2.3