Skip to content

Commit

Permalink
authenticated_s3_url now allows a :symbol thumbnail name
Browse files Browse the repository at this point in the history
  • Loading branch information
nbibler committed Jun 26, 2008
1 parent e475cf7 commit a74ea92
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/technoweenie/attachment_fu/backends/s3_backend.rb
Expand Up @@ -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

Expand Down
12 changes: 12 additions & 0 deletions test/backends/remote/s3_test.rb
Expand Up @@ -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
Expand Down

0 comments on commit a74ea92

Please sign in to comment.