Permalink
Browse files

Merge pull request #44 from mcary/use-copy-options

Merge in options passed to S3Object.copy.
  • Loading branch information...
marcel committed Nov 9, 2011
2 parents 5cd500f + bd25b25 commit 1ec3ff9d39dc3dd7ec5ea68278b9fbd1dbe87a88
Showing with 16 additions and 1 deletion.
  1. +1 −1 lib/aws/s3/object.rb
  2. +15 −0 test/object_test.rb
View
@@ -184,7 +184,7 @@ def copy(key, copy_key, bucket = nil, options = {})
source_key = path!(bucket, key) source_key = path!(bucket, key)
default_options = {'x-amz-copy-source' => source_key} default_options = {'x-amz-copy-source' => source_key}
target_key = path!(bucket, copy_key) target_key = path!(bucket, copy_key)
returning put(target_key, default_options) do returning put(target_key, default_options.merge(options)) do
acl(copy_key, bucket, acl(key, bucket)) if options[:copy_acl] acl(copy_key, bucket, acl(key, bucket)) if options[:copy_acl]
end end
end end
View
@@ -148,6 +148,21 @@ def test_fetching_information_about_an_object_that_does_not_exist_raises_no_such
S3Object.about('asdfasdfasdfas-this-does-not-exist', 'bucket does not matter') S3Object.about('asdfasdfasdfas-this-does-not-exist', 'bucket does not matter')
end end
end end
def test_copy_options_are_used
options = {'x-amz-storage-class' => 'REDUCED_REDUNDANCY'}
resp = FakeResponse.new
connection = flexmock('Mock connection') do |mock|
mock.should_receive(:request).
# The storage-class key must be passed to connection.request(:put, ...)
with(:put, '/some-bucket/new', hsh(options), any, any).
and_return(resp)
end
flexmock(S3Object).should_receive(:connection).and_return(connection)
result = S3Object.copy('old', 'new', 'some-bucket', options)
assert_equal resp.code, result.code
end
end end
class MetadataTest < Test::Unit::TestCase class MetadataTest < Test::Unit::TestCase

0 comments on commit 1ec3ff9

Please sign in to comment.