Permalink
Browse files

Merge branch 'question_mark_files' of https://github.com/xxx/paperclip

  • Loading branch information...
2 parents b09b05b + 11a09fb commit ff48f6886343ed13db904722145946c6a619f5a2 @mike-burns mike-burns committed Nov 16, 2011
Showing with 42 additions and 2 deletions.
  1. BIN test/fixtures/question?mark.png
  2. +2 −0 test/helper.rb
  3. +40 −2 test/storage/s3_live_test.rb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -12,6 +12,8 @@
require 'mime/types'
require 'pathname'
+require 'pathname'
+
puts "Testing against version #{ActiveRecord::VERSION::STRING}"
`ruby -e 'exit 0'` # Prime $? with a value.
@@ -9,7 +9,7 @@ class S3LiveTest < Test::Unit::TestCase
:storage => :s3,
:bucket => ENV["S3_TEST_BUCKET"],
:path => ":class/:attachment/:id/:style.:extension",
- :s3_credentials => File.new(File.join(File.dirname(__FILE__), "..", "s3.yml"))
+ :s3_credentials => File.new(File.join(File.dirname(__FILE__), "..", "fixtures", "s3.yml"))
Dummy.delete_all
@dummy = Dummy.new
@@ -56,7 +56,7 @@ class S3LiveTest < Test::Unit::TestCase
rebuild_model :styles => { :thumb => "100x100", :square => "32x32#" },
:storage => :s3,
:bucket => ENV["S3_TEST_BUCKET"],
- :s3_credentials => File.new(File.join(File.dirname(__FILE__), "..", "s3.yml"))
+ :s3_credentials => File.new(File.join(File.dirname(__FILE__), "..", "fixtures", "s3.yml"))
Dummy.delete_all
@dummy = Dummy.new
@@ -84,5 +84,43 @@ class S3LiveTest < Test::Unit::TestCase
assert_match /404 Not Found/, `curl -I #{url}`
end
end
+
+ context "An attachment that uses S3 for storage and has a question mark in file name" do
+ setup do
+ rebuild_model :styles => { :thumb => "100x100", :square => "32x32#" },
+ :storage => :s3,
+ :bucket => ENV["S3_TEST_BUCKET"],
+ :s3_credentials => File.new(File.join(File.dirname(__FILE__), "..", "fixtures", "s3.yml"))
+
+ Dummy.delete_all
+ @dummy = Dummy.new
+ @dummy.avatar = File.new(File.join(File.dirname(__FILE__), '..', 'fixtures', 'question?mark.png'), 'rb')
+ @dummy.save
+ end
+
+ teardown { @dummy.destroy }
+
+ should "return an unescaped version for path" do
+ assert_match /.+\/question\?mark\.png/, @dummy.avatar.path
+ end
+
+# should "return an escaped version for url" do
+# assert_match /.+\/question%3Fmark\.png/, @dummy.avatar.url
+# end
+
+ should "be accessible" do
+ assert_match /200 OK/, `curl -I "#{@dummy.avatar.url}"`
+ end
+
+ should "be accessible with an expiring url" do
+ assert_match /200 OK/, `curl -I "#{@dummy.avatar.expiring_url}"`
+ end
+
+ should "be destroyable" do
+ url = @dummy.avatar.url
+ @dummy.destroy
+ assert_match /404 Not Found/, `curl -I "#{url}"`
+ end
+ end
end
end

0 comments on commit ff48f68

Please sign in to comment.