Skip to content

Commit

Permalink
Allow deleting all files for multiple file upload. Fixes #1990
Browse files Browse the repository at this point in the history
  • Loading branch information
mshibuya committed Jun 18, 2019
1 parent 7db9195 commit 19c97c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/carrierwave/mounter.rb
Expand Up @@ -41,7 +41,7 @@ def uploaders
end

def cache(new_files)
return if new_files.blank?
return if !new_files.is_a?(Array) && new_files.blank?
old_uploaders = uploaders
@uploaders = new_files.map do |new_file|
handle_error do
Expand Down
10 changes: 10 additions & 0 deletions spec/mount_multiple_spec.rb
Expand Up @@ -309,6 +309,16 @@ def monkey
expect { instance.store_images! }.not_to raise_error
expect(instance.images.map(&:identifier)).to be_empty
end

it "allows deleting all files" do
instance.images = []
expect(instance.images.map(&:identifier)).to be_empty
end

it "allows assignment of uploader instances" do
instance.images = [instance.images[0]]
expect(instance.images.map(&:identifier)).to eq ['bork.txt']
end
end
end

Expand Down

0 comments on commit 19c97c7

Please sign in to comment.