Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit 8110922ed6cb55d2d9d780b36256fef05342b493 1 parent 1ebe840
@michiels michiels authored mike-burns committed
View
8 Gemfile.lock
@@ -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
View
9 lib/paperclip/storage/fog.rb
@@ -120,7 +120,7 @@ def public_url(style = default_style)
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 @@ def dynamic_fog_host_for_style(style)
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
View
2  paperclip.gemspec
@@ -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')
View
12 test/storage/fog_test.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.