Commit 86cddc6e by Michiel Sikkes Committed by Mike Burns

Fix using using default path and url options for Fog storage

* Added test for checking if path gets interpolated correctly without passing
  :path or :url options
* gsub default :rails_root filesystem-like path to nothing for Fog storage,
  just like in S3 Storage.
parent 39717c69
......@@ -42,7 +42,7 @@ module Paperclip
base.instance_eval do
unless @options[:url].to_s.match(/^:fog.*url$/)
@options[:path] = @options[:path].gsub(/:url/, @options[:url])
@options[:path] = @options[:path].gsub(/:url/, @options[:url]).gsub(/^:rails_root\/public\/system\//, '')
@options[:url] = ':fog_public_url'
end
Paperclip.interpolates(:fog_public_url) do |attachment, style|
......
......@@ -67,6 +67,29 @@ class FogTest < Test::Unit::TestCase
end
end
context "with no path or url given and using defaults" do
setup do
rebuild_model :styles => { :medium => "300x300>", :thumb => "100x100>" },
:storage => :fog,
:fog_directory => "paperclip",
:fog_credentials => {
:provider => 'AWS',
:aws_access_key_id => 'AWS_ID',
:aws_secret_access_key => 'AWS_SECRET'
}
@file = File.new(fixture_file('5k.png'), 'rb')
@dummy = Dummy.new
@dummy.id = 1
@dummy.avatar = @file
end
teardown { @file.close }
should "have correct path and url from interpolated defaults" do
assert_equal "dummies/avatars/000/000/001/original/5k.png", @dummy.avatar.path
end
end
setup do
@fog_directory = 'papercliptests'
......
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