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