public
Description: Treat an ActiveRecord model as a file attachment, storing its patch, size, content type, etc.
Homepage: http://weblog.techno-weenie.net
Clone URL: git://github.com/technoweenie/attachment_fu.git
Click here to lend your support to: attachment_fu and make a donation at www.pledgie.com !
authenticated_s3_url now allows a :symbol thumbnail name
nbibler (author)
Wed Jun 25 19:08:14 -0700 2008
commit  a74ea929dd0d061da887872f8cde07016524dcc4
tree    cf513104782dcb9eada0845447f5449674d1422f
parent  e475cf78a49ede1ba6c83fdae7028d7d9da4cd85
...
236
237
238
239
240
 
 
241
242
243
...
236
237
238
 
 
239
240
241
242
243
0
@@ -236,8 +236,8 @@ module Technoweenie # :nodoc:
0
         #
0
         # @photo.authenticated_s3_url('thumbnail', :expires_in => 5.hours, :use_ssl => true)
0
         def authenticated_s3_url(*args)
0
- thumbnail = args.first.is_a?(String) ? args.first : nil
0
- options = args.last.is_a?(Hash) ? args.last : {}
0
+ options = args.extract_options!
0
+ thumbnail = args.shift
0
           S3Object.url_for(full_filename(thumbnail), bucket_name, options)
0
         end
0
 
...
49
50
51
 
 
 
 
 
 
 
 
 
 
 
 
52
53
54
...
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
0
@@ -49,6 +49,18 @@ class S3Test < Test::Unit::TestCase
0
     end
0
 
0
     test_against_subclass :test_should_create_authenticated_url, S3Attachment
0
+
0
+ def test_should_create_authenticated_url_for_thumbnail(klass = S3Attachment)
0
+ attachment_model klass
0
+ attachment = upload_file :filename => '/files/rails.png'
0
+ ['large', :large].each do |thumbnail|
0
+ assert_match(
0
+ /^http.+rails_large\.png.+AWSAccessKeyId.+Expires.+Signature/,
0
+ attachment.authenticated_s3_url(thumbnail),
0
+ "authenticated_s3_url failed with #{thumbnail.class} parameter"
0
+ )
0
+ end
0
+ end
0
 
0
     def test_should_save_attachment(klass = S3Attachment)
0
       attachment_model klass

Comments

    No one has commented yet.