Skip to content

Commit

Permalink
Always convert s3_protocol to string first
Browse files Browse the repository at this point in the history
  • Loading branch information
sikachu committed Jun 15, 2012
1 parent e90de5d commit 95d7c4a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/paperclip/storage/s3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ def s3_permissions(style = default_style)

def s3_protocol(style = default_style)
protocol = if @s3_protocol.respond_to?(:call)
@s3_protocol.call(style, self)
@s3_protocol.call(style, self).to_s
else
@s3_protocol
@s3_protocol.to_s
end

protocol = protocol.split(":").first + ":" unless protocol.empty?
Expand Down
16 changes: 16 additions & 0 deletions test/storage/s3_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,22 @@ def teardown
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
setup do
rebuild_model :storage => :s3,
Expand Down

0 comments on commit 95d7c4a

Please sign in to comment.