aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2017-04-21 12:23:49 -0400
committerRafael Mendonça França <rafaelmfranca@gmail.com>2017-04-21 12:23:49 -0400
commit128b804c6ce40fcbde744f294f8cb98654f6efec (patch)
tree37f69f303bf4b5015fdbfcbd9bc4e60de2d8c0e4 /actionview/test/template
parentd766e3dc5dde086ef1b391e30c8c4b6d8b682a35 (diff)
downloadrails-128b804c6ce40fcbde744f294f8cb98654f6efec.tar.gz
rails-128b804c6ce40fcbde744f294f8cb98654f6efec.tar.bz2
rails-128b804c6ce40fcbde744f294f8cb98654f6efec.zip
Configure form_with_generates_remote_forms in its own initializer
This configuration is not present in ActionView::Base so we can't let the action_view.set_configs initializer set it. Also add tests to make sure this config works. Fixes #28824
Diffstat (limited to 'actionview/test/template')
-rw-r--r--actionview/test/template/form_helper/form_with_test.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/actionview/test/template/form_helper/form_with_test.rb b/actionview/test/template/form_helper/form_with_test.rb
index a4a2966ff9..a09dd468dd 100644
--- a/actionview/test/template/form_helper/form_with_test.rb
+++ b/actionview/test/template/form_helper/form_with_test.rb
@@ -729,6 +729,28 @@ class FormWithActsLikeFormForTest < FormWithTest
assert_dom_equal expected, output_buffer
end
+ def test_form_is_not_remote_by_default_if_form_with_generates_remote_forms_is_false
+ old_value = ActionView::Helpers::FormHelper.form_with_generates_remote_forms
+ ActionView::Helpers::FormHelper.form_with_generates_remote_forms = false
+
+ form_with(model: @post, url: "/", id: "create-post", method: :patch) do |f|
+ concat f.text_field(:title)
+ concat f.text_area(:body)
+ concat f.check_box(:secret)
+ end
+
+ expected = whole_form("/", "create-post", method: "patch", local: true) do
+ "<input name='post[title]' type='text' value='Hello World' />" \
+ "<textarea name='post[body]'>\nBack to the hill and over it again!</textarea>" \
+ "<input name='post[secret]' type='hidden' value='0' />" \
+ "<input name='post[secret]' checked='checked' type='checkbox' value='1' />"
+ end
+
+ assert_dom_equal expected, output_buffer
+ ensure
+ ActionView::Helpers::FormHelper.form_with_generates_remote_forms = old_value
+ end
+
def test_form_with_skip_enforcing_utf8_true
form_with(scope: :post, skip_enforcing_utf8: true) do |f|
concat f.text_field(:title)