From bc84048c41b2d42f38191634865f4304726ada8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janko=20Marohni=C4=87?= Date: Sat, 5 Dec 2015 04:11:53 +0100 Subject: [PATCH] Apply :endpoint option to Bucket#presigned_post `Object#presigned_post` properly passes the bucket's url (which is affected by the `:endpoint` option), so to keep consistency we make `Bucket#presigned_post` pass it as well. --- .../lib/aws-sdk-resources/services/s3/bucket.rb | 3 ++- aws-sdk-resources/spec/services/s3/bucket_spec.rb | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/aws-sdk-resources/lib/aws-sdk-resources/services/s3/bucket.rb b/aws-sdk-resources/lib/aws-sdk-resources/services/s3/bucket.rb index e93e24a974e..ba90be131f3 100644 --- a/aws-sdk-resources/lib/aws-sdk-resources/services/s3/bucket.rb +++ b/aws-sdk-resources/lib/aws-sdk-resources/services/s3/bucket.rb @@ -93,7 +93,8 @@ def presigned_post(options = {}) client.config.credentials, client.config.region, name, - options) + {url: url}.merge(options) + ) end # @api private diff --git a/aws-sdk-resources/spec/services/s3/bucket_spec.rb b/aws-sdk-resources/spec/services/s3/bucket_spec.rb index a783fe9a1d8..67b9cfe0c95 100644 --- a/aws-sdk-resources/spec/services/s3/bucket_spec.rb +++ b/aws-sdk-resources/spec/services/s3/bucket_spec.rb @@ -5,14 +5,22 @@ module S3 class Bucket describe '#presigned_post' do - let(:object) { Bucket.new('bucket', stub_responses: true) } + def bucket(options = {}) + options[:stub_responses] ||= true + Bucket.new('bucket', options) + end it 'creates a presigned post without a key' do - post = object.presigned_post(key: 'foo', acl: 'public-read') + post = bucket.presigned_post(key: 'foo', acl: 'public-read') expect(post.fields['key']).to eq('foo') expect(post.fields['acl']).to eq('public-read') end + it 'applies the :endpoint option' do + post = bucket(endpoint: 'http://foo.com').presigned_post(key: 'foo') + expect(post.url).to eq('http://bucket.foo.com') + end + end end end