Added test for template to layout variable transfer

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1904 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson 2005-07-23 08:43:01 +00:00
parent 023c4d68cc
commit d172592985
4 changed files with 17 additions and 2 deletions

@ -724,7 +724,7 @@ def redirect_to(options = {}, *parameters_for_method_reference) #:doc:
#
# This method will overwrite an existing Cache-Control header.
# See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html for more possibilities.
def expires_in(seconds, options = {})
def expires_in(seconds, options = {}) #:doc:
cache_options = { 'max-age' => seconds, 'private' => true }.symbolize_keys.merge!(options.symbolize_keys)
cache_options.delete_if { |k,v| v.nil? or v == false }
cache_control = cache_options.map{ |k,v| v == true ? k.to_s : "#{k.to_s}=#{v.to_s}"}
@ -733,7 +733,7 @@ def expires_in(seconds, options = {})
# Sets a HTTP 1.1 Cache-Control header of "no-cache" so no caching should occur by the browser or
# intermediate caches (like caching proxy servers).
def expires_now
def expires_now #:doc:
@response.headers["Cache-Control"] = "no-cache"
end

@ -119,6 +119,10 @@ def rendering_with_conflicting_local_vars
render :action => "potential_conflicts"
end
def action_talk_to_layout
# Action template sets variable that's picked up by layout
end
def rescue_action(e) raise end
private
@ -133,6 +137,8 @@ def determine_layout
"layouts/standard"
when "builder_layout_test"
"layouts/builder"
when "action_talk_to_layout"
"layouts/talk_from_action"
end
end
end
@ -293,6 +299,11 @@ def test_rendering_with_conflicting_local_vars
assert_equal("First: David\nSecond: Stephan\nThird: David\nFourth: David\nFifth: ", @response.body)
end
def test_action_talk_to_layout
get :action_talk_to_layout
assert_equal "<title>Talking to the layout</title>\nAction was here!", @response.body
end
# def test_partials_list
# get :partials_list
# assert_equal "goodbyeHello: davidHello: marygoodbye\n", @response.body

@ -0,0 +1,2 @@
<title><%= @title %></title>
<%= @content_for_layout -%>

@ -0,0 +1,2 @@
<% @title = "Talking to the layout" -%>
Action was here!