Permalink
Browse files

Merge branch 'master' of git@github.com:squarelover/attachment_fu

* 'master' of git@github.com:squarelover/attachment_fu:
  authenticated_s3_url now allows a :symbol thumbnail name
  • Loading branch information...
2 parents d2da9f3 + a74ea92 commit 287472f285fd3629990625af873929a19197e5a1 Sean Wolfe committed Sep 16, 2008
Showing with 14 additions and 2 deletions.
  1. +2 −2 lib/technoweenie/attachment_fu/backends/s3_backend.rb
  2. +12 −0 test/backends/remote/s3_test.rb
View
4 lib/technoweenie/attachment_fu/backends/s3_backend.rb
@@ -236,8 +236,8 @@ def s3_url(thumbnail = nil)
#
# @photo.authenticated_s3_url('thumbnail', :expires_in => 5.hours, :use_ssl => true)
def authenticated_s3_url(*args)
- thumbnail = args.first.is_a?(String) ? args.first : nil
- options = args.last.is_a?(Hash) ? args.last : {}
+ options = args.extract_options!
+ thumbnail = args.shift
S3Object.url_for(full_filename(thumbnail), bucket_name, options)
end
View
12 test/backends/remote/s3_test.rb
@@ -49,6 +49,18 @@ def test_should_create_authenticated_url(klass = S3Attachment)
end
test_against_subclass :test_should_create_authenticated_url, S3Attachment
+
+ def test_should_create_authenticated_url_for_thumbnail(klass = S3Attachment)
+ attachment_model klass
+ attachment = upload_file :filename => '/files/rails.png'
+ ['large', :large].each do |thumbnail|
+ assert_match(
+ /^http.+rails_large\.png.+AWSAccessKeyId.+Expires.+Signature/,
+ attachment.authenticated_s3_url(thumbnail),
+ "authenticated_s3_url failed with #{thumbnail.class} parameter"
+ )
+ end
+ end
def test_should_save_attachment(klass = S3Attachment)
attachment_model klass

0 comments on commit 287472f

Please sign in to comment.