Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Added a test for Attachment#uploaded_file
Browse files Browse the repository at this point in the history
  • Loading branch information
Overbryd authored and mike-burns committed Oct 21, 2011
1 parent 24b0c5a commit 7cc0921
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/paperclip/attachment.rb
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/attachment_test.rb
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/helper.rb
@@ -1,5 +1,6 @@
require 'rubygems'
require 'tempfile'
require 'pathname'
require 'test/unit'

require 'shoulda'
Expand Down

0 comments on commit 7cc0921

Please sign in to comment.