diff --git a/lib/fog/aws/models/s3/buckets.rb b/lib/fog/aws/models/s3/buckets.rb index bdf5b1226..1d3cb4de1 100644 --- a/lib/fog/aws/models/s3/buckets.rb +++ b/lib/fog/aws/models/s3/buckets.rb @@ -11,7 +11,7 @@ module Fog def all data = connection.get_service.body owner = Fog::AWS::S3::Owner.new(data.delete('Owner').merge!(:connection => connection)) - buckets = [] + buckets = Fog::AWS::S3::Buckets.new data['Buckets'].each do |bucket| buckets << Fog::AWS::S3::Bucket.new({ :connection => connection, diff --git a/lib/fog/aws/s3.rb b/lib/fog/aws/s3.rb index ac9275497..57e4c56b0 100644 --- a/lib/fog/aws/s3.rb +++ b/lib/fog/aws/s3.rb @@ -122,7 +122,7 @@ DATA canonical_resource << "#{subdomain}/" end canonical_resource << "#{params[:path]}" - if ['acl', 'location', 'logging', 'torrent'].include?(params[:query]) + if ['acl', 'location', 'logging', 'requestPayment', 'torrent'].include?(params[:query]) canonical_resource << "?#{params[:query]}" end string_to_sign << "#{canonical_resource}" diff --git a/lib/fog/collection.rb b/lib/fog/collection.rb index c850b7377..7cbd8bd52 100644 --- a/lib/fog/collection.rb +++ b/lib/fog/collection.rb @@ -1,5 +1,5 @@ module Fog - class Collection + class Collection < Array def initialize(attributes = {}) update_attributes(attributes) @@ -10,11 +10,11 @@ module Fog for attribute in (self.instance_variables - ['@connection']) data << " #{attribute}=#{send(attribute[1..-1].to_sym).inspect}" end - data << "[" - self.each do |element| - data << "#{element.inspect}, " + data << " [" + for item in self + data << "#{item.inspect}," end - data = data[0..-3] + data.chomp! data << "]>" end @@ -22,6 +22,7 @@ module Fog for key, value in attributes send(:"#{key}=", value) end + self end private @@ -34,9 +35,13 @@ module Fog @connection end + def new_record? + !defined?(@new_record) || @new_record + end + def remap_attributes(attributes, mapping) for key, value in mapping - if attributes[key] + if attributes.key?(key) attributes[value] = attributes.delete(key) end end diff --git a/lib/fog/model.rb b/lib/fog/model.rb index 8bdee5b3f..f0a0173d2 100644 --- a/lib/fog/model.rb +++ b/lib/fog/model.rb @@ -36,7 +36,7 @@ module Fog def remap_attributes(attributes, mapping) for key, value in mapping - if mapping[key] + if attributes.key?(key) attributes[value] = attributes.delete(key) end end diff --git a/spec/aws/models/s3/buckets_spec.rb b/spec/aws/models/s3/buckets_spec.rb index b5a51b9d5..afce3b54c 100644 --- a/spec/aws/models/s3/buckets_spec.rb +++ b/spec/aws/models/s3/buckets_spec.rb @@ -23,8 +23,9 @@ describe 'S3.buckets' do end it "should push bucket down into objects" do - p @bucket = @s3.buckets.create(:name => 'fogbucketspaymenttest') + p @bucket = @s3.buckets.create(:name => 'fogbucketsobjectstest') p @bucket.objects.new(:key => 'object') + p @bucket.objects.all p @bucket.delete end