Commit 95d7c4a1 by Prem Sichanugrist

Always convert s3_protocol to string first

Fixes #883
parent e90de5da
...@@ -278,9 +278,9 @@ module Paperclip ...@@ -278,9 +278,9 @@ module Paperclip
def s3_protocol(style = default_style) def s3_protocol(style = default_style)
protocol = if @s3_protocol.respond_to?(:call) protocol = if @s3_protocol.respond_to?(:call)
@s3_protocol.call(style, self) @s3_protocol.call(style, self).to_s
else else
@s3_protocol @s3_protocol.to_s
end end
protocol = protocol.split(":").first + ":" unless protocol.empty? protocol = protocol.split(":").first + ":" unless protocol.empty?
......
...@@ -144,6 +144,22 @@ class S3Test < Test::Unit::TestCase ...@@ -144,6 +144,22 @@ class S3Test < Test::Unit::TestCase
end end
end end
context ":s3_protocol => :https" do
setup do
rebuild_model :storage => :s3,
:s3_credentials => {},
:s3_protocol => :https,
:bucket => "bucket",
:path => ":attachment/:basename.:extension"
@dummy = Dummy.new
@dummy.avatar = StringIO.new(".")
end
should "return a url based on an S3 path" do
assert_match %r{^https://s3.amazonaws.com/bucket/avatars/stringio.txt}, @dummy.avatar.url
end
end
context ":s3_protocol => ''" do context ":s3_protocol => ''" do
setup do setup 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