aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-09-08 18:03:17 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-09-08 18:04:45 -0300
commitfb110381481fe79fa2921d08a60d343d3ea2b363 (patch)
tree7fafaaa38bf6fe0ccf68736cde10a878c683c98d /actionview
parent8683396dd8c31c70ba9332586ee05889305fdde6 (diff)
downloadrails-fb110381481fe79fa2921d08a60d343d3ea2b363.tar.gz
rails-fb110381481fe79fa2921d08a60d343d3ea2b363.tar.bz2
rails-fb110381481fe79fa2921d08a60d343d3ea2b363.zip
Do not memoize document_root_element in view tests
Memoizing will not make possible to assert the output of the view if it is changed after the first assert_select call Related with plataformatec/simple_form#1130 and rails/rails-dom-testing#15
Diffstat (limited to 'actionview')
-rw-r--r--actionview/lib/action_view/test_case.rb3
-rw-r--r--actionview/test/template/test_case_test.rb11
2 files changed, 12 insertions, 2 deletions
diff --git a/actionview/lib/action_view/test_case.rb b/actionview/lib/action_view/test_case.rb
index 7edfc436a6..af34d2ce5a 100644
--- a/actionview/lib/action_view/test_case.rb
+++ b/actionview/lib/action_view/test_case.rb
@@ -158,8 +158,7 @@ module ActionView
# Need to experiment if this priority is the best one: rendered => output_buffer
def document_root_element
- @html_document ||= Nokogiri::HTML::Document.parse(@rendered.blank? ? @output_buffer : @rendered)
- @html_document.root
+ Nokogiri::HTML::Document.parse(@rendered.blank? ? @output_buffer : @rendered).root
end
def say_no_to_protect_against_forgery!
diff --git a/actionview/test/template/test_case_test.rb b/actionview/test/template/test_case_test.rb
index 4582fa13ee..5697ffa317 100644
--- a/actionview/test/template/test_case_test.rb
+++ b/actionview/test/template/test_case_test.rb
@@ -293,6 +293,17 @@ module ActionView
assert_select 'li', :text => 'foo'
end
end
+
+ test "do not memoize the document_root_element in view tests" do
+ concat form_tag('/foo')
+
+ assert_select 'form'
+
+ concat content_tag(:b, 'Strong', class: 'foo')
+
+ assert_select 'form'
+ assert_select 'b.foo'
+ end
end
class RenderTemplateTest < ActionView::TestCase