Commit 8110922e by Michiel Sikkes Committed by Mike Burns

Fix the Fog storage expiring_url method for the new Fog release

* Fixed tests and functionality for new fog and removed the fixed version from the gemspec
* Set time to 3600 from the current time so expiring actually works
parent 1ebe8402
......@@ -71,12 +71,12 @@ GEM
json (>= 1.4.6)
diff-lcs (1.1.3)
erubis (2.7.0)
excon (0.13.4)
excon (0.14.3)
fakeweb (1.3.0)
ffi (1.0.11)
fog (1.3.1)
fog (1.4.0)
builder
excon (~> 0.13.0)
excon (~> 0.14.0)
formatador (~> 0.2.0)
mime-types
multi_json (~> 1.0)
......@@ -187,7 +187,7 @@ DEPENDENCIES
cocaine (~> 0.2)
cucumber (~> 1.2.1)
fakeweb
fog (= 1.3.1)
fog (~> 1.4.0)
jruby-openssl
launchy
mocha
......
......@@ -120,7 +120,7 @@ module Paperclip
end
end
def expiring_url(time = 3600, style = default_style)
def expiring_url(time = (Time.now + 3600), style = default_style)
expiring_url = directory.files.get_http_url(path(style), time)
if @options[:fog_host]
......@@ -159,12 +159,7 @@ module Paperclip
def host_name_for_directory
if @options[:fog_directory].to_s =~ Fog::AWS_BUCKET_SUBDOMAIN_RESTRICTON_REGEX
# This:
"#{@options[:fog_directory]}."
# Should be modified to this:
# "#{@options[:fog_directory]}.s3.amazonaws.com"
# When fog with https://github.com/fog/fog/pull/857 gets released
"#{@options[:fog_directory]}.s3.amazonaws.com"
else
"s3.amazonaws.com/#{@options[:fog_directory]}"
end
......
......@@ -43,7 +43,7 @@ Gem::Specification.new do |s|
s.add_development_dependency('capybara')
s.add_development_dependency('bundler')
s.add_development_dependency('cocaine', '~> 0.2')
s.add_development_dependency('fog', '1.3.1')
s.add_development_dependency('fog', '~> 1.4.0')
s.add_development_dependency('pry')
s.add_development_dependency('launchy')
s.add_development_dependency('rake')
......
......@@ -234,19 +234,11 @@ class FogTest < Test::Unit::TestCase
context "with a valid bucket name for a subdomain" do
should "provide an url in subdomain style" do
# The following line is the correct one when this pull request in Fog is released:
# https://github.com/fog/fog/pull/857
# assert_match /^http:\/\/papercliptests.s3.amazonaws.com\/avatars\/5k.png\?AWSAccessKeyId=.+$/, @dummy.avatar.expiring_url
# For now, use this passing one:
assert_match /^https:\/\/papercliptests.\/avatars\/5k.png\?\d*$/, @dummy.avatar.url
assert_match @dummy.avatar.url, /^https:\/\/papercliptests.s3.amazonaws.com\/avatars\/5k.png/
end
should "provide an url that expires in subdomain style" do
# The following line is the correct one when this pull request in Fog is released:
# https://github.com/fog/fog/pull/857
# assert_match /^http:\/\/papercliptests.s3.amazonaws.com\/avatars\/5k.png\?AWSAccessKeyId=.+$/, @dummy.avatar.expiring_url
# For now, use this passing one:
assert_match /^http:\/\/papercliptests.\/avatars\/5k.png\?AWSAccessKeyId=.+$/, @dummy.avatar.expiring_url
assert_match /^http:\/\/papercliptests.s3.amazonaws.com\/avatars\/5k.png\?AWSAccessKeyId=.+$/, @dummy.avatar.expiring_url
end
end
......
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