Commit 07e0330e by Pablo Cantero

Add a test case for protocol-relative URL

parent a424b82d
...@@ -51,7 +51,7 @@ module Paperclip ...@@ -51,7 +51,7 @@ module Paperclip
# :s3_permissions => :private # :s3_permissions => :private
# #
# * +s3_protocol+: The protocol for the URLs generated to your S3 assets. Can be either # * +s3_protocol+: The protocol for the URLs generated to your S3 assets. Can be either
# 'http', 'https', or an empty string to generate scheme-less URLs. Defaults to 'http' # 'http', 'https', or an empty string to generate protocol-relative URLs. Defaults to 'http'
# when your :s3_permissions are :public_read (the default), and 'https' when your # when your :s3_permissions are :public_read (the default), and 'https' when your
# :s3_permissions are anything else. # :s3_permissions are anything else.
# * +s3_headers+: A hash of headers or a Proc. You may specify a hash such as # * +s3_headers+: A hash of headers or a Proc. You may specify a hash such as
......
...@@ -152,6 +152,22 @@ describe Paperclip::Storage::S3 do ...@@ -152,6 +152,22 @@ describe Paperclip::Storage::S3 do
end end
end end
context "s3_protocol: ''" do
before do
rebuild_model storage: :s3,
s3_credentials: {},
s3_protocol: '',
bucket: "bucket",
path: ":attachment/:basename:dotextension"
@dummy = Dummy.new
@dummy.avatar = stringy_file
end
it "returns a protocol-relative URL" do
assert_match %r{^//s3.amazonaws.com/bucket/avatars/data[^\.]}, @dummy.avatar.url
end
end
context "s3_protocol: :https" do context "s3_protocol: :https" do
before do before do
rebuild_model storage: :s3, rebuild_model storage: :s3,
......
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