Commit 822de421 by Alex Godin

Merge branch 'master' of github.com:thoughtbot/paperclip

parents a51811de 8d262e30
...@@ -99,6 +99,11 @@ module Paperclip ...@@ -99,6 +99,11 @@ module Paperclip
attachment.instance.id attachment.instance.id
end end
# Returns the #to_param of the instance.
def param attachment, style_name
attachment.instance.to_param
end
# Returns the fingerprint of the instance. # Returns the fingerprint of the instance.
def fingerprint attachment, style_name def fingerprint attachment, style_name
attachment.fingerprint attachment.fingerprint
......
...@@ -34,20 +34,20 @@ class IntegrationTest < Test::Unit::TestCase ...@@ -34,20 +34,20 @@ class IntegrationTest < Test::Unit::TestCase
should "create its thumbnails properly" do should "create its thumbnails properly" do
assert_match /\b50x50\b/, `identify "#{@dummy.avatar.path(:thumb)}"` assert_match /\b50x50\b/, `identify "#{@dummy.avatar.path(:thumb)}"`
end end
context 'reprocessing with unreadable original' do context 'reprocessing with unreadable original' do
setup { File.chmod(0000, @dummy.avatar.path) } setup { File.chmod(0000, @dummy.avatar.path) }
should "not raise an error" do should "not raise an error" do
assert_nothing_raised do assert_nothing_raised do
@dummy.avatar.reprocess! @dummy.avatar.reprocess!
end end
end end
should "return false" do should "return false" do
assert ! @dummy.avatar.reprocess! assert ! @dummy.avatar.reprocess!
end end
teardown { File.chmod(0644, @dummy.avatar.path) } teardown { File.chmod(0644, @dummy.avatar.path) }
end end
...@@ -467,6 +467,18 @@ class IntegrationTest < Test::Unit::TestCase ...@@ -467,6 +467,18 @@ class IntegrationTest < Test::Unit::TestCase
@files_on_s3 = s3_files_for @dummy.avatar @files_on_s3 = s3_files_for @dummy.avatar
end end
context 'assigning itself to a new model' do
setup do
@d2 = Dummy.new
@d2.avatar = @dummy.avatar
@d2.save
end
should "have the same name as the old file" do
assert_equal @d2.avatar.original_filename, @dummy.avatar.original_filename
end
end
should "have the same contents as the original" do should "have the same contents as the original" do
@file.rewind @file.rewind
assert_equal @file.read, @files_on_s3[:original].read assert_equal @file.read, @files_on_s3[:original].read
......
...@@ -50,6 +50,13 @@ class InterpolationsTest < Test::Unit::TestCase ...@@ -50,6 +50,13 @@ class InterpolationsTest < Test::Unit::TestCase
assert_equal "png", Paperclip::Interpolations.extension(attachment, :style) assert_equal "png", Paperclip::Interpolations.extension(attachment, :style)
end end
should "return the #to_param of the attachment" do
attachment = mock
attachment.expects(:to_param).returns("23-awesome")
attachment.expects(:instance).returns(attachment)
assert_equal "23-awesome", Paperclip::Interpolations.param(attachment, :style)
end
should "return the id of the attachment" do should "return the id of the attachment" do
attachment = mock attachment = mock
attachment.expects(:id).returns(23) attachment.expects(:id).returns(23)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment