Fix for ActiveStorage::Attached::Many

This commit is contained in:
Mike Enriquez 2020-05-01 13:54:11 -04:00
parent ea9ed80322
commit b4e17c4970
3 changed files with 10 additions and 0 deletions

View File

@ -591,6 +591,7 @@ module SimpleForm
# Returns a Boolean.
def file_method?(attribute_name)
@object.respond_to?("#{attribute_name}_attachment") ||
@object.respond_to?("#{attribute_name}_attachments") ||
@object.respond_to?("remote_#{attribute_name}_url") ||
@object.respond_to?("#{attribute_name}_attacher") ||
@object.respond_to?("#{attribute_name}_file_name")

View File

@ -244,6 +244,11 @@ class FormBuilderTest < ActionView::TestCase
assert_select 'form input#user_with_attachment_avatar.file'
end
test 'builder generates file input for ActiveStorage::Attached::Many' do
with_form_for UserWithAttachment.build, :avatars
assert_select 'form input#user_with_attachment_avatars.file'
end
test 'builder generates file input for Refile >= 0.3.0 and CarrierWave >= 0.2.2' do
with_form_for UserWithAttachment.build, :cover
assert_select 'form input#user_with_attachment_cover.file'

View File

@ -339,6 +339,10 @@ class UserWithAttachment < User
OpenStruct.new
end
def avatars_attachments
OpenStruct.new
end
def remote_cover_url
"/uploads/cover.png"
end