public
Description: Paperclip File Management Plugin
Homepage: http://www.thoughtbot.com/projects/paperclip
Clone URL: git://github.com/thoughtbot/paperclip.git
Added ability for S3 bucket to be in the config file, environmentally 
scoped.
jyurek (author)
Fri Sep 12 14:03:40 -0700 2008
commit  ce2f389a7539b2501557f57fab6536a9cc79cb88
tree    ebcf6387353b729bcef3508cc8ae03a444fb6608
parent  457c0cd516125feab6c5121af28825cba53521d7
...
105
106
107
108
109
 
110
111
112
...
105
106
107
 
108
109
110
111
112
0
@@ -105,8 +105,8 @@ module Paperclip
0
       def self.extended base
0
         require 'right_aws'
0
         base.instance_eval do
0
- @bucket = @options[:bucket]
0
           @s3_credentials = parse_credentials(@options[:s3_credentials])
0
+ @bucket = @options[:bucket] || @s3_credentials[:bucket]
0
           @s3_options = @options[:s3_options] || {}
0
           @s3_permissions = @options[:s3_permissions] || 'public-read'
0
           @s3_protocol = @options[:s3_protocol] || (@s3_permissions == 'public-read' ? 'http' : 'https')
...
156
157
158
159
 
160
161
162
...
186
187
188
189
 
190
191
192
...
156
157
158
 
159
160
161
162
...
186
187
188
 
189
190
191
192
0
@@ -156,7 +156,7 @@ class AttachmentTest < Test::Unit::TestCase
0
       @not_file.expects(:to_tempfile).returns(self)
0
       @not_file.expects(:original_filename).returns("filename.png\r\n")
0
       @not_file.expects(:content_type).returns("image/png\r\n")
0
- @not_file.expects(:size).returns(10)
0
+ @not_file.expects(:size).returns(10).times(2)
0
       
0
       @dummy = Dummy.new
0
       @attachment = @dummy.avatar
0
@@ -186,7 +186,7 @@ class AttachmentTest < Test::Unit::TestCase
0
       @not_file.expects(:to_tempfile).returns(self)
0
       @not_file.expects(:original_filename).returns("sheep_say_bæ.png\r\n")
0
       @not_file.expects(:content_type).returns("image/png\r\n")
0
- @not_file.expects(:size).returns(10)
0
+ @not_file.expects(:size).returns(10).times(2)
0
       
0
       @dummy = Dummy.new
0
       @attachment = @dummy.avatar
...
42
43
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
46
47
...
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
0
@@ -42,6 +42,25 @@ class StorageTest < Test::Unit::TestCase
0
     end
0
   end
0
 
0
+ context "Parsing S3 credentials with a bucket in them" do
0
+ setup do
0
+ rebuild_model :storage => :s3,
0
+ :s3_credentials => {
0
+ :production => { :bucket => "prod_bucket" },
0
+ :development => { :bucket => "dev_bucket" }
0
+ }
0
+ @dummy = Dummy.new
0
+ end
0
+
0
+ should "get the right bucket in production", :before => lambda{ ENV.expects(:[]).returns('production') } do
0
+ assert_equal "prod_bucket", @dummy.avatar.bucket_name
0
+ end
0
+
0
+ should "get the right bucket in development", :before => lambda{ ENV.expects(:[]).returns('development') } do
0
+ assert_equal "dev_bucket", @dummy.avatar.bucket_name
0
+ end
0
+ end
0
+
0
   context "An attachment with S3 storage" do
0
     setup do
0
       rebuild_model :storage => :s3,
...
119
120
121
122
 
123
124
125
...
119
120
121
 
122
123
124
125
0
@@ -119,7 +119,7 @@ class ThumbnailTest < Test::Unit::TestCase
0
 
0
       should "send the right command to convert when sent #make" do
0
         @thumb.expects(:system).with do |arg|
0
- arg.match %r{convert\s+"#{File.expand_path(@thumb.file.path)}"\s+-scale\s+\"x50\"\s+-crop\s+\"100x50\+114\+0\"\s+\+repage\s+-strip\s+-depth\s+8\s+".*?"}
0
+ arg.match %r{convert\s+"#{File.expand_path(@thumb.file.path)}\[0\]"\s+-resize\s+"x50"\s+-crop\s+"100x50\+114\+0"\s+\+repage\s+-strip\s+-depth\s+8\s+".*?"}
0
         end
0
         @thumb.make
0
       end

Comments

    No one has commented yet.