Permalink
Browse files

Properly load the storage modules.

  • Loading branch information...
1 parent 56d6b24 commit 4f85dd441bd5119ea0ab5406fbd9a713e289eb8d @jyurek jyurek committed Aug 18, 2010
Showing with 22 additions and 2 deletions.
  1. +2 −2 lib/paperclip/attachment.rb
  2. +20 −0 test/attachment_test.rb
@@ -276,9 +276,9 @@ def valid_assignment? file #:nodoc:
def initialize_storage #:nodoc:
storage_name = @storage.to_s.capitalize
begin
- require "paperclip/storage/#{storage_name}"
+ require "paperclip/storage/#{@storage}"
rescue MissingSourceFile
- raise StorageMethodNotFound, "Cannot find #{storage_name}"
+ raise StorageMethodNotFound, "Cannot find the '#{@storage}' storage adapter."
end
@storage_module = Paperclip::Storage.const_get(storage_name)
self.extend(@storage_module)
@@ -338,6 +338,26 @@ class Paperclip::Test < Paperclip::Processor; end
end
end
+ should "include the filesystem module when loading the filesystem storage" do
+ rebuild_model :storage => :filesystem
+ @dummy = Dummy.new
+ assert @dummy.avatar.is_a?(Paperclip::Storage::Filesystem)
+ end
+
+ should "include the filesystem module even if capitalization is wrong" do
+ rebuild_model :storage => :FileSystem
+ @dummy = Dummy.new
+ assert @dummy.avatar.is_a?(Paperclip::Storage::Filesystem)
+ end
+
+ should "raise an error if you try to include a storage module that doesn't exist" do
+ rebuild_model :storage => :not_here
+ @dummy = Dummy.new
+ assert_raises(Paperclip::StorageMethodNotFound) do
+ @dummy.avatar
+ end
+ end
+
context "An attachment with styles but no processors defined" do
setup do
rebuild_model :processors => [], :styles => {:something => '1'}

0 comments on commit 4f85dd4

Please sign in to comment.