From 87d6cb379d8cffd3f12b2dab6248ff3e8f830307 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sat, 22 Apr 2017 12:27:25 +0900 Subject: Set to `form_with_generates_remote_forms` only when config is explicitly specified Without this check, even if config is not specified, `ActionView::Helpers::FormHelper.form_with_generates_remote_forms` always be set to nil and remote form not be generated. Follow up to 128b804c6ce40fcbde744f294f8cb98654f6efec --- railties/test/application/configuration_test.rb | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'railties/test') diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 32eab74190..07c6afed7f 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -725,6 +725,34 @@ module ApplicationTests assert_no_match(/data-remote/, last_response.body) end + test "form_with generates remote forms by default" do + app_file "app/models/post.rb", <<-RUBY + class Post + include ActiveModel::Model + attr_accessor :name + end + RUBY + + app_file "app/controllers/posts_controller.rb", <<-RUBY + class PostsController < ApplicationController + def index + render inline: "<%= begin; form_with(model: Post.new) {|f| f.text_field(:name)}; rescue => e; e.to_s; end %>" + end + end + RUBY + + add_to_config <<-RUBY + routes.prepend do + resources :posts + end + RUBY + + app "development" + + get "/posts" + assert_match(/data-remote/, last_response.body) + end + test "default method for update can be changed" do app_file "app/models/post.rb", <<-RUBY class Post -- cgit v1.2.3