test/storage_test.rb in thoughtbot-paperclip-2.2.6 vs test/storage_test.rb in thoughtbot-paperclip-2.2.7

- old
+ new

@@ -35,9 +35,58 @@ ENV['RAILS_ENV'] = "not really an env" assert_equal({:test => "12345"}, @avatar.parse_credentials(:test => "12345")) end end + context "" do + setup do + rebuild_model :storage => :s3, + :s3_credentials => {}, + :bucket => "bucket", + :path => ":attachment/:basename.:extension", + :url => ":s3_path_url" + @dummy = Dummy.new + @dummy.avatar = StringIO.new(".") + end + + should "return a url based on an S3 path" do + assert_match %r{^http://s3.amazonaws.com/bucket/avatars/stringio.txt}, @dummy.avatar.url + end + end + context "" do + setup do + rebuild_model :storage => :s3, + :s3_credentials => {}, + :bucket => "bucket", + :path => ":attachment/:basename.:extension", + :url => ":s3_domain_url" + @dummy = Dummy.new + @dummy.avatar = StringIO.new(".") + end + + should "return a url based on an S3 subdomain" do + assert_match %r{^http://bucket.s3.amazonaws.com/avatars/stringio.txt}, @dummy.avatar.url + end + end + context "" do + setup do + rebuild_model :storage => :s3, + :s3_credentials => { + :production => { :bucket => "prod_bucket" }, + :development => { :bucket => "dev_bucket" } + }, + :s3_host_alias => "something.something.com", + :path => ":attachment/:basename.:extension", + :url => ":s3_alias_url" + @dummy = Dummy.new + @dummy.avatar = StringIO.new(".") + end + + should "return a url based on the host_alias" do + assert_match %r{^http://something.something.com/avatars/stringio.txt}, @dummy.avatar.url + end + end + context "Parsing S3 credentials with a bucket in them" do setup do rebuild_model :storage => :s3, :s3_credentials => { :production => { :bucket => "prod_bucket" },