From ebee0a742d40f87bb9b78d5d88393c341761cfad Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 17 May 2007 20:48:47 +0000 Subject: Added url_for usage on render :location, which allows for record identification [DHH] (still need to figure out why that test doesnt pass, seems like a test issue) git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6750 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/new_render_test.rb | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb index 18a32f6e30..fa27a1794b 100644 --- a/actionpack/test/controller/new_render_test.rb +++ b/actionpack/test/controller/new_render_test.rb @@ -1,6 +1,9 @@ require File.dirname(__FILE__) + '/../abstract_unit' -silence_warnings { Customer = Struct.new("Customer", :name) } +silence_warnings { Customer = Struct.new(:name, :id) } + +class CustomersController < ActionController::Base +end module Fun class GamesController < ActionController::Base @@ -261,6 +264,11 @@ class NewRenderTestController < ActionController::Base def render_with_location render :xml => "", :location => "http://example.com", :status => 201 end + + def render_with_object_location + customer = Customer.new("Some guy", 1) + render :xml => "", :location => customer_url(customer), :status => :created + end def render_with_to_xml to_xmlable = Class.new do @@ -766,4 +774,14 @@ EOS get :render_with_to_xml assert_equal "", @response.body end + + def test_rendering_with_object_location_should_set_header_with_url_for + ActionController::Routing::Routes.draw do |map| + map.resources :customers + map.connect ':controller/:action/:id' + end + + get :render_with_object_location + assert_equal "http://test.host/customers/1", @response.headers["Location"] + end end \ No newline at end of file -- cgit v1.2.3