This bug is related to earlier tickets 5448 and 4631 (search in Trac for html_document). The problem is that the line @html_document in the process methon in integration.rb has no effect since that instance variable is not copied over from the session to the testcase.
I wanted to add a test to reproduce the problem. However the test/controller/integration_test.rb stubs out the process method so I couldn't use that test case, at least not as it is.
The steps I used to reproduce were (on Mac OSX):
1) sudo gem install rails --source http://gems.rubyonrails.org --include-dependencies
2) rails test
3) cd test; rake rails:freeze:edge
4) ./script/generate controller Home; ./script/generate integration_test home
5) create a file app/views/home/foo.rhtml and app/views/home/bar.rhtml that contain the words foo and bar respectively.
6) Edit the test/integration/home_test.rb to be:
require "#{File.dirname(__FILE__)}/../test_helper"
class HomeTest < ActionController::IntegrationTest
def test_foo_and_bar
get "/home/foo"
assert html_document.root.to_s =~ /foo/i
get "/home/bar"
assert html_document.root.to_s =~ /bar/i
end
end
7) ruby test/integration/home_test.rb and watch the test fail.
8) Make the following change to integration.rb:
Index: actionpack/lib/action_controller/integration.rb
===================================================================
--- actionpack/lib/action_controller/integration.rb (revision 5717)
+++ actionpack/lib/action_controller/integration.rb (working copy)
@@ -534,7 +534,7 @@
# test instance.
def copy_session_variables! #:nodoc:
return unless @integration_session
- %w(controller response request).each do |var|
+ %w(controller response request html_document).each do |var|
instance_variable_set("@#{var}", @integration_session.send(var))
end
end
An alternative fix to the recurring problem with html_document would be to make the html_document method always recreate the document when invoked.