Skip to content

Commit

Permalink
add a test with form_for and a separate view context that causes trou…
Browse files Browse the repository at this point in the history
…ble.
  • Loading branch information
apotonick committed Apr 13, 2014
1 parent 800095b commit dc5fb5c
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/helper_test.rb
Expand Up @@ -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(<<HAML, "inline template", handler, {})
= form_for(m, :url => "/") do |f|
%b Bold!
HAML

assert_equal "<b>Bold!</b>", template.render(HomemadeViewContext.new, {})
end

def test_find_and_preserve_with_block
assert_equal("<pre>Foo&#x000A;Bar</pre>\nFoo\nBar\n",
render("= find_and_preserve do\n %pre\n Foo\n Bar\n Foo\n Bar"))
Expand Down

0 comments on commit dc5fb5c

Please sign in to comment.