Skip to content
Browse files

Merge remote branch 'tilsammans/master'

  • Loading branch information...
2 parents 208883d + 88a65aa commit 7a38ef79d00f858b474a00207ef537372a8e30f7 @jyurek jyurek committed Jan 14, 2011
Showing with 49 additions and 1 deletion.
  1. +7 −1 README.rdoc
  2. +3 −0 lib/paperclip/attachment.rb
  3. +16 −0 test/integration_test.rb
  4. +23 −0 test/storage_test.rb
View
8 README.rdoc
@@ -15,14 +15,20 @@ useful defaults.
See the documentation for +has_attached_file+ in Paperclip::ClassMethods for
more detailed options.
-The complete RDoc[http://rdoc.info/projects/thoughtbot/paperclip] is online.
+The complete RDoc[http://rdoc.info/gems/paperclip] is online.
==Installation
Include the gem in your Gemfile:
gem "paperclip", "~> 2.3"
+==Installation
+
+As a plugin:
+
+ ruby script/plugin install git://github.com/thoughtbot/paperclip.git
+
==Quick Start
In your model:
View
3 lib/paperclip/attachment.rb
@@ -235,6 +235,9 @@ def reprocess!
else
true
end
+ rescue Errno::EACCES => e
+ warn "#{e} - skipping file"
+ false
end
# Returns true if a file has been assigned.
View
16 test/integration_test.rb
@@ -34,6 +34,22 @@ class IntegrationTest < Test::Unit::TestCase
should "create its thumbnails properly" do
assert_match /\b50x50\b/, `identify "#{@dummy.avatar.path(:thumb)}"`
end
+
+ context 'reprocessing with unreadable original' do
+ setup { File.chmod(0000, @dummy.avatar.path) }
+
+ should "not raise an error" do
+ assert_nothing_raised do
+ @dummy.avatar.reprocess!
+ end
+ end
+
+ should "return false" do
+ assert ! @dummy.avatar.reprocess!
+ end
+
+ teardown { File.chmod(0644, @dummy.avatar.path) }
+ end
context "redefining its attachment styles" do
setup do
View
23 test/storage_test.rb
@@ -7,6 +7,29 @@ def rails_env(env)
Object.const_set(:Rails, stub('Rails', :env => env))
end
end
+
+ context "filesystem" do
+ setup do
+ rebuild_model :styles => { :thumbnail => "25x25#" }
+ @dummy = Dummy.create!
+
+ @dummy.avatar = File.open(File.join(File.dirname(__FILE__), "fixtures", "5k.png"))
+ end
+
+ should "allow file assignment" do
+ assert @dummy.save
+ end
+
+ should "store the original" do
+ @dummy.save
+ assert File.exists?(@dummy.avatar.path)
+ end
+
+ should "store the thumbnail" do
+ @dummy.save
+ assert File.exists?(@dummy.avatar.path(:thumbnail))
+ end
+ end
context "Parsing S3 credentials" do
setup do

0 comments on commit 7a38ef7

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