diff --git a/lib/fog/aws/requests/storage/get_bucket.rb b/lib/fog/aws/requests/storage/get_bucket.rb index f9a3b0ff7..62b36e203 100644 --- a/lib/fog/aws/requests/storage/get_bucket.rb +++ b/lib/fog/aws/requests/storage/get_bucket.rb @@ -69,7 +69,7 @@ module Fog end response = Excon::Response.new if bucket = self.data[:buckets][bucket_name] - contents = bucket[:objects].values.collect(&:last).sort {|x,y| x['Key'] <=> y['Key']}.reject do |object| + contents = bucket[:objects].values.collect(&:first).sort {|x,y| x['Key'] <=> y['Key']}.reject do |object| (prefix && object['Key'][0...prefix.length] != prefix) || (marker && object['Key'] <= marker) || (delimiter && object['Key'][(prefix ? prefix.length : 0)..-1].include?(delimiter) \ diff --git a/tests/aws/requests/storage/versioning_tests.rb b/tests/aws/requests/storage/versioning_tests.rb index 8fa173fdf..89689c854 100644 --- a/tests/aws/requests/storage/versioning_tests.rb +++ b/tests/aws/requests/storage/versioning_tests.rb @@ -134,6 +134,22 @@ Shindo.tests('Fog::Storage[:aws] | versioning', [:aws]) do end end + tests("get_bucket('#{@aws_bucket_name}'") do + clear_bucket + + file = Fog::Storage[:aws].directories.get(@aws_bucket_name).files.create(:body => 'a', :key => 'file') + + tests("includes a non-DeleteMarker object").returns(1) do + Fog::Storage[:aws].get_bucket(@aws_bucket_name).body['Contents'].size + end + + file.destroy + + tests("does not include a DeleteMarker object").returns(0) do + Fog::Storage[:aws].get_bucket(@aws_bucket_name).body['Contents'].size + end + end + delete_bucket end