Skip to content
Browse files

Allow empty files to be uploaded

  • Loading branch information...
1 parent 7e5913b commit a09a36e708e8ece1e35f777fed9de6ecb2185129 @Arjeno committed Oct 15, 2011
Showing with 1 addition and 9 deletions.
  1. +1 −1 lib/carrierwave/sanitized_file.rb
  2. +0 −8 spec/sanitized_file_spec.rb
View
2 lib/carrierwave/sanitized_file.rb
@@ -132,7 +132,7 @@ def is_path?
# [Boolean] whether the file is valid and has a non-zero size
#
def empty?
- @file.nil? || self.size.nil? || self.size.zero?
+ @file.nil? || self.size.nil? || (self.size.zero? && ! self.file.is_a?(File))
end
##
View
8 spec/sanitized_file_spec.rb
@@ -32,14 +32,6 @@
@sanitized_file.should be_empty
end
- it "should be empty for a file with a zero size" do
- FileUtils.rm file_path('llama.jpg')
- FileUtils.touch file_path('llama.jpg')
-
- @sanitized_file = CarrierWave::SanitizedFile.new(File.open(file_path('llama.jpg')))
- @sanitized_file.should be_empty
- end
-
end
describe '#original_filename' do

0 comments on commit a09a36e

Please sign in to comment.
Something went wrong with that request. Please try again.