mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
In #4342, part of the functionalities of form_for was delegated to form_with, this could potentially cause some regress, as the condition to send polymorphic_path(record, {}) instead of polymorphic_path(record, format: options.delete(:format)) is removed and when format is not passed, this causes issues if the caller is not expecting an extra arg format:nil. This PR adds back the condition inside for with and add a test to make sure it doesn't break for_with
This commit is contained in:
parent
2b6182cbd6
commit
c92ac83fe6
2 changed files with 17 additions and 1 deletions
|
@ -754,7 +754,11 @@ module ActionView
|
|||
|
||||
if model
|
||||
if url != false
|
||||
url ||= polymorphic_path(model, format: format)
|
||||
url ||= if format.nil?
|
||||
polymorphic_path(model, {})
|
||||
else
|
||||
polymorphic_path(model, format: format)
|
||||
end
|
||||
end
|
||||
|
||||
model = _object_for_form_builder(model)
|
||||
|
|
|
@ -2057,6 +2057,18 @@ class FormHelperTest < ActionView::TestCase
|
|||
assert_dom_equal expected, output_buffer
|
||||
end
|
||||
|
||||
def test_new_form_for_without_format
|
||||
form_for(@post, html: { id: "edit_post_123", class: "edit_post" }) do |f|
|
||||
concat f.label(:title)
|
||||
end
|
||||
|
||||
expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do
|
||||
"<label for='post_title'>Title</label>"
|
||||
end
|
||||
|
||||
assert_dom_equal expected, output_buffer
|
||||
end
|
||||
|
||||
def test_form_for_with_model_using_relative_model_naming
|
||||
blog_post = Blog::Post.new("And his name will be forty and four.", 44)
|
||||
|
||||
|
|
Loading…
Reference in a new issue