aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/new_render_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/controller/new_render_test.rb')
-rw-r--r--actionpack/test/controller/new_render_test.rb20
1 files changed, 19 insertions, 1 deletions
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 => "<hello/>", :location => "http://example.com", :status => 201
end
+
+ def render_with_object_location
+ customer = Customer.new("Some guy", 1)
+ render :xml => "<customer/>", :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 "<i-am-xml/>", @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