Permalink
Browse files

authenticated_s3_url now allows a :symbol thumbnail name

  • Loading branch information...
nbibler committed Jun 26, 2008
1 parent e475cf7 commit a74ea929dd0d061da887872f8cde07016524dcc4
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
@@ -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
@@ -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 a74ea92

Please sign in to comment.