Commit 435ecba0 by Mike Breen Committed by Chad Pytel

expiring_url should set the :use_ssl flag when calling S3Object.url_for

parent 7003961d
......@@ -95,7 +95,7 @@ module Paperclip
end
def expiring_url(time = 3600)
AWS::S3::S3Object.url_for(path, bucket_name, :expires_in => time )
AWS::S3::S3Object.url_for(path, bucket_name, :expires_in => time, :use_ssl => (s3_protocol == 'https'))
end
def bucket_name
......
......@@ -114,6 +114,34 @@ class StorageTest < Test::Unit::TestCase
end
end
context "Generating a secure url with an expiration" do
setup do
AWS::S3::Base.stubs(:establish_connection!)
rebuild_model :storage => :s3,
:s3_credentials => {
:production => { :bucket => "prod_bucket" },
:development => { :bucket => "dev_bucket" }
},
:s3_host_alias => "something.something.com",
:s3_permissions => "private",
:path => ":attachment/:basename.:extension",
:url => ":s3_alias_url"
rails_env("production")
@dummy = Dummy.new
@dummy.avatar = StringIO.new(".")
AWS::S3::S3Object.expects(:url_for).with("avatars/stringio.txt", "prod_bucket", { :expires_in => 3600, :use_ssl => true })
@dummy.avatar.expiring_url
end
should "should succeed" do
assert true
end
end
context "Generating a url with an expiration" do
setup do
AWS::S3::Base.stubs(:establish_connection!)
......@@ -131,7 +159,7 @@ class StorageTest < Test::Unit::TestCase
@dummy = Dummy.new
@dummy.avatar = StringIO.new(".")
AWS::S3::S3Object.expects(:url_for).with("avatars/stringio.txt", "prod_bucket", { :expires_in => 3600 })
AWS::S3::S3Object.expects(:url_for).with("avatars/stringio.txt", "prod_bucket", { :expires_in => 3600, :use_ssl => false })
@dummy.avatar.expiring_url
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