Permalink
Browse files

Added a test for Attachment#uploaded_file

  • Loading branch information...
1 parent 1655bf2 commit 58a17e64240e730871249c513a8f0291a12e124a @Overbryd Overbryd committed Oct 18, 2011
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
@@ -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)
@@ -208,7 +208,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
@@ -825,6 +825,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,5 +1,6 @@
require 'rubygems'
require 'tempfile'
+require 'pathname'
require 'test/unit'
require 'shoulda'

0 comments on commit 58a17e6

Please sign in to comment.