1
0
Fork 0
mirror of https://github.com/heartcombo/simple_form.git synced 2022-11-09 12:19:26 -05:00

Merge pull request #1697 from enriquez/fix-activestorage-manu

Fix for ActiveStorage::Attached::Many
This commit is contained in:
Felipe Renan 2020-05-04 20:46:57 +03:00 committed by GitHub
commit 7d016d8cc5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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