From d4c61c81902cfabd664fb291c8885f294a8fb70d Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 8 Feb 2012 12:39:14 -0500 Subject: [PATCH] [aws|storage|test] Fixed a regression with mocked get_bucket requests, due to a change in the mock data ordering. --- lib/fog/aws/requests/storage/get_bucket.rb | 2 +- tests/aws/requests/storage/versioning_tests.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) 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