Skip to content
Browse files

Merge pull request #5288 from lest/patch-2

force response body to be read in assert_template
Conflicts:
	actionpack/lib/action_controller/test_case.rb
  • Loading branch information...
1 parent d3dcb4b commit a5013bb5af299db6bf97f67d4198220280717e80 @josevalim josevalim committed with carlosantoniodasilva Mar 5, 2012
View
6 actionpack/CHANGELOG.md
@@ -1,5 +1,11 @@
## Rails 3.2.12 (unreleased) ##
+* Fix `assert_template` with `render :stream => true`.
+ Fix #1743.
+ Backport #5288.
+
+ *Sergey Nartimov*
+
* Eagerly populate the http method loookup cache so local project inflections do
not interfere with use of underscore method ( and we don't need locks )
View
2 actionpack/lib/action_controller/test_case.rb
@@ -70,6 +70,8 @@ def process(*args)
#
def assert_template(options = {}, message = nil)
validate_request!
+ # Force body to be read in case the template is being streamed
+ response.body
case options
when NilClass, String, Symbol
View
13 actionpack/test/controller/layout_test.rb
@@ -78,6 +78,13 @@ def test_namespaced_controllers_auto_detect_layouts2
class DefaultLayoutController < LayoutTest
end
+class StreamingLayoutController < LayoutTest
+ def render(*args)
+ options = args.extract_options!
+ super(*args, options.merge(:stream => true))
+ end
+end
+
class AbsolutePathLayoutController < LayoutTest
layout File.expand_path(File.expand_path(__FILE__) + '/../../fixtures/layout_tests/layouts/layout_test')
end
@@ -122,6 +129,12 @@ def test_layout_set_when_using_default_layout
assert_template :layout => "layouts/layout_test"
end
+ def test_layout_set_when_using_streaming_layout
+ @controller = StreamingLayoutController.new
+ get :hello
+ assert_template :hello
+ end
+
def test_layout_set_when_set_in_controller
@controller = HasOwnLayoutController.new
get :hello

0 comments on commit a5013bb

Please sign in to comment.
Something went wrong with that request. Please try again.