Commit 8dd016dd by Jon Yurek

Fixed double/no slashes on new s3 url builder.

Put merged tests in the right place.
parent 269ba250
...@@ -53,7 +53,7 @@ module Paperclip ...@@ -53,7 +53,7 @@ module Paperclip
@url = ":s3_url" @url = ":s3_url"
end end
base.class.interpolations[:s3_url] = lambda do |attachment, style| base.class.interpolations[:s3_url] = lambda do |attachment, style|
"https://s3.amazonaws.com/#{attachment.bucket_name}#{attachment.path(style)}" "https://s3.amazonaws.com/#{attachment.bucket_name}/#{attachment.path(style).gsub(%r{^/}, "")}"
end end
end end
......
...@@ -111,15 +111,6 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -111,15 +111,6 @@ class AttachmentTest < Test::Unit::TestCase
assert_equal "/tests/blah/missing.png", @attachment.url(:blah) assert_equal "/tests/blah/missing.png", @attachment.url(:blah)
end end
should "return the proper path when filename has a single .'s" do
assert_equal "./test/../tmp/tests/dummies/original/41/5k.png", @attachment.path
end
should "return the proper path when filename has multiple .'s" do
@instance.stubs(:[]).with(:test_file_name).returns("5k.old.png")
assert_equal "./test/../tmp/tests/dummies/original/41/5k.old.png", @attachment.path
end
context "with a file assigned in the database" do context "with a file assigned in the database" do
setup do setup do
@instance.stubs(:[]).with(:test_file_name).returns("5k.png") @instance.stubs(:[]).with(:test_file_name).returns("5k.png")
...@@ -132,6 +123,15 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -132,6 +123,15 @@ class AttachmentTest < Test::Unit::TestCase
assert_equal "/tests/41/blah/5k.png", @attachment.url(:blah) assert_equal "/tests/41/blah/5k.png", @attachment.url(:blah)
end end
should "return the proper path when filename has a single .'s" do
assert_equal "./test/../tmp/tests/dummies/original/41/5k.png", @attachment.path
end
should "return the proper path when filename has multiple .'s" do
@instance.stubs(:[]).with(:test_file_name).returns("5k.old.png")
assert_equal "./test/../tmp/tests/dummies/original/41/5k.old.png", @attachment.path
end
context "when expecting three styles" do context "when expecting three styles" do
setup do setup do
styles = {:styles => { :large => ["400x400", :png], styles = {:styles => { :large => ["400x400", :png],
......
...@@ -127,6 +127,7 @@ class IntegrationTest < Test::Unit::TestCase ...@@ -127,6 +127,7 @@ class IntegrationTest < Test::Unit::TestCase
if ENV['S3_TEST_BUCKET'] if ENV['S3_TEST_BUCKET']
def s3_files_for attachment def s3_files_for attachment
[:thumb, :medium, :large, :original].inject({}) do |files, style| [:thumb, :medium, :large, :original].inject({}) do |files, style|
p attachment.url(style)
data = `curl '#{attachment.url(style)}' 2>/dev/null`.chomp data = `curl '#{attachment.url(style)}' 2>/dev/null`.chomp
t = Tempfile.new("paperclip-test") t = Tempfile.new("paperclip-test")
t.write(data) t.write(data)
......
...@@ -46,7 +46,7 @@ class StorageTest < Test::Unit::TestCase ...@@ -46,7 +46,7 @@ class StorageTest < Test::Unit::TestCase
setup do setup do
rebuild_model :storage => :s3, rebuild_model :storage => :s3,
:bucket => "testing", :bucket => "testing",
:path => "/:attachment/:style/:basename.:extension", :path => ":attachment/:style/:basename.:extension",
:s3_credentials => { :s3_credentials => {
'access_key_id' => "12345", 'access_key_id' => "12345",
'secret_access_key' => "54321" 'secret_access_key' => "54321"
......
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