Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 1ec3ff9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/aws/s3/object.rb
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions test/object_test.rb
Expand Up @@ -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
Expand Down

0 comments on commit 1ec3ff9

Please sign in to comment.