diff options
Diffstat (limited to 'actionpack/test/template/form_helper_test.rb')
-rw-r--r-- | actionpack/test/template/form_helper_test.rb | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 7da293ce23..5c6cb45530 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -1,6 +1,5 @@ require 'abstract_unit' require 'controller/fake_models' -require 'active_support/core_ext/object/inclusion' class FormHelperTest < ActionView::TestCase include RenderERBUtils @@ -1046,6 +1045,20 @@ class FormHelperTest < ActionView::TestCase end end + def test_form_for_requires_arguments + error = assert_raises(ArgumentError) do + form_for(nil, :html => { :id => 'create-post' }) do + end + end + assert_equal "First argument in form cannot contain nil or be empty", error.message + + error = assert_raises(ArgumentError) do + form_for([nil, nil], :html => { :id => 'create-post' }) do + end + end + assert_equal "First argument in form cannot contain nil or be empty", error.message + end + def test_form_for form_for(@post, :html => { :id => 'create-post' }) do |f| concat f.label(:title) { "The Title" } @@ -2638,6 +2651,12 @@ class FormHelperTest < ActionView::TestCase assert_dom_equal expected, output_buffer end + def test_form_for_with_data_attributes + form_for(@post, data: { behavior: "stuff" }, remote: true) {} + assert_match %r|data-behavior="stuff"|, output_buffer + assert_match %r|data-remote="true"|, output_buffer + end + def test_fields_for_returns_block_result output = fields_for(Post.new) { |f| "fields" } assert_equal "fields", output @@ -2660,7 +2679,7 @@ class FormHelperTest < ActionView::TestCase def hidden_fields(method = nil) txt = %{<div style="margin:0;padding:0;display:inline">} txt << %{<input name="utf8" type="hidden" value="✓" />} - if method && !method.to_s.in?(['get', 'post']) + if method && !%w(get post).include?(method.to_s) txt << %{<input name="_method" type="hidden" value="#{method}" />} end txt << %{</div>} |