Skip to content
Browse files

Added a test for Attachment#uploaded_file

  • Loading branch information...
1 parent 24b0c5a commit 7cc0921aeef88bd473c1af92bcd79d5777a7e3f4 @Overbryd Overbryd committed with mike-burns
Showing with 7 additions and 2 deletions.
  1. +2 −2 lib/paperclip/attachment.rb
  2. +4 −0 test/attachment_test.rb
  3. +1 −0 test/helper.rb
View
4 lib/paperclip/attachment.rb
@@ -95,7 +95,7 @@ def assign uploaded_file
uploaded_file = uploaded_file.to_file(:original)
close_uploaded_file = uploaded_file.respond_to?(:close)
else
- instance_write(:uploaded_file, uploaded_file)
+ instance_write(:uploaded_file, uploaded_file) if uploaded_file
end
return nil unless valid_assignment?(uploaded_file)
@@ -209,7 +209,7 @@ def uploaded_file
def original_filename
instance_read(:file_name)
end
-
+
# Returns the size of the file as originally assigned, and lives in the
# <attachment>_file_size attribute of the model.
def size
View
4 test/attachment_test.rb
@@ -855,6 +855,10 @@ def do_after_all; end
assert @attachment.dirty?
end
+ should "set uploaded_file for access beyond the paperclip lifecycle" do
+ assert_equal @file, @attachment.uploaded_file
+ end
+
context "and saved" do
setup do
@attachment.save
View
1 test/helper.rb
@@ -1,5 +1,6 @@
require 'rubygems'
require 'tempfile'
+require 'pathname'
require 'test/unit'
require 'shoulda'

0 comments on commit 7cc0921

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