Commit 6c912c4d by Jon Yurek

Fixes an infinite interpolation problem with fog

parent 3f56e703
......@@ -47,7 +47,10 @@ module Paperclip
@fog_public = @options.key?(:fog_public) ? @options[:fog_public] : true
@fog_file = @options[:fog_file] || {}
unless @url.to_s.match(/^:fog.*url$/)
@path = @path.gsub(/:url/, @url)
@url = ':fog_public_url'
end
Paperclip.interpolates(:fog_public_url) do |attachment, style|
attachment.public_url(style)
end unless Paperclip::Interpolations.respond_to? :fog_public_url
......
......@@ -5,6 +5,26 @@ Fog.mock!
class FogTest < Test::Unit::TestCase
context "" do
context "with default values for path and url" do
setup do
rebuild_model :styles => { :medium => "300x300>", :thumb => "100x100>" },
:storage => :fog,
:url => '/:attachment/:filename',
:fog_directory => "paperclip",
:fog_credentials => {
:provider => 'AWS',
:aws_access_key_id => 'AWS_ID',
:aws_secret_access_key => 'AWS_SECRET'
}
@dummy = Dummy.new
@dummy.avatar = File.new(File.join(File.dirname(__FILE__), 'fixtures', '5k.png'), 'rb')
end
should "be able to interpolate the path without blowing up" do
puts @dummy.avatar.instance_variable_get("@path")
assert_equal File.join(File.dirname(File.expand_path(__FILE__)),
"../public/avatars/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