From dc5fb5c29ff9591a12fcf58bc6916c8c5fe97c91 Mon Sep 17 00:00:00 2001 From: Nick Sutterer Date: Mon, 14 Apr 2014 09:49:20 +1000 Subject: [PATCH] add a test with form_for and a separate view context that causes trouble. --- test/helper_test.rb | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/helper_test.rb b/test/helper_test.rb index 9754322040..f137441901 100644 --- a/test/helper_test.rb +++ b/test/helper_test.rb @@ -468,6 +468,45 @@ def check_capture_returns_nil(&block) assert_equal("\n", render("= check_capture_returns_nil { 2 }", :action_view)) end + + class HomemadeViewContext + include ActionView::Context + include ActionView::Helpers::FormHelper + + def url_for(*) + "/" + end + + def dom_class(*) + end + + def dom_id(*) + end + + def m + FormFormObject.new + end + + def protect_against_forgery? + end + end + + require "active_model/naming" + class FormFormObject + extend ActiveModel::Naming + end + + def test_form_for_with_homemade_view_context + handler = ActionView::Template.handler_for_extension("haml") + template = ActionView::Template.new(< "/") do |f| + %b Bold! +HAML + + assert_equal "Bold!", template.render(HomemadeViewContext.new, {}) + end + def test_find_and_preserve_with_block assert_equal("
Foo
Bar
\nFoo\nBar\n", render("= find_and_preserve do\n %pre\n Foo\n Bar\n Foo\n Bar"))