Commit 4f85dd44 by Jon Yurek

Properly load the storage modules.

parent 56d6b240
......@@ -276,9 +276,9 @@ module Paperclip
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 AttachmentTest < Test::Unit::TestCase
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'}
......
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