Browse files

[aws|storage|test] Added versioning tests for Versions collection.

  • Loading branch information...
1 parent 0287c0f commit 9d02af6f7a9e3c0e8f3be177b7b7508a986e3d1e @nirvdrum nirvdrum committed Jan 26, 2012
View
2 lib/fog/aws/models/storage/versions.rb
@@ -14,7 +14,7 @@ class Versions < Fog::Collection
def all
data = if file
- connection.get_bucket_object_versions(file.directory.key, :prefix => file.key).body['Versions']
+ connection.get_bucket_object_versions(file.directory.key, 'prefix' => file.key).body['Versions']
else
connection.get_bucket_object_versions(directory.key).body['Versions']
end
View
22 tests/aws/models/storage/directory_tests.rb
@@ -50,26 +50,4 @@
end
- model_tests(Fog::Storage[:aws].directories, directory_attributes, Fog.mocking?) do
- @instance.versioning = true
-
- versions = []
- versions << @instance.connection.put_object(@instance.key, 'one', 'abcde').headers['x-amz-version-id']
- versions << @instance.connection.put_object(@instance.key, 'one', '32423').headers['x-amz-version-id']
- versions << @instance.connection.delete_object(@instance.key, 'one').headers['x-amz-version-id']
- versions << @instance.connection.put_object(@instance.key, 'two', 'aoeu').headers['x-amz-version-id']
-
- tests('#versions') do
- tests('#versions.size includes versions (including DeleteMarkers) for all keys').returns(4) do
- @instance.versions.size
- end
-
- tests('#versions returns the correct versions').returns(versions) do
- @instance.versions.collect(&:version)
- end
- end
-
- @instance.versions.each(&:destroy)
- end
-
end
View
51 tests/aws/models/storage/versions_tests.rb
@@ -0,0 +1,51 @@
+Fog.mock!
+
+Shindo.tests("Storage[:aws] | versions", [:aws]) do
+
+ file_attributes = {
+ :key => 'fog_file_tests',
+ :body => lorem_file,
+ :public => true
+ }
+
+ directory_attributes = {
+ :key => 'fogfilestests'
+ }
+
+ model_tests(Fog::Storage[:aws].directories, directory_attributes, Fog.mocking?) do
+ @instance.versioning = true
+
+ versions = []
+ versions << @instance.connection.put_object(@instance.key, 'one', 'abcde').headers['x-amz-version-id']
+ versions << @instance.connection.put_object(@instance.key, 'one', '32423').headers['x-amz-version-id']
+ versions << @instance.connection.delete_object(@instance.key, 'one').headers['x-amz-version-id']
+ versions << @instance.connection.put_object(@instance.key, 'two', 'aoeu').headers['x-amz-version-id']
+
+ tests('#versions') do
+ tests('#versions.size includes versions (including DeleteMarkers) for all keys').returns(4) do
+ @instance.versions.size
+ end
+
+ tests('#versions returns the correct versions').returns(versions) do
+ @instance.versions.collect(&:version)
+ end
+ end
+
+ tests("#all") do
+ tests("#all for a directory returns all versions, regardless of key").returns(versions) do
+ @instance.versions.all.collect(&:version)
+ end
+
+ tests("#all for file returns only versions for that file").returns(1) do
+ @instance.files.get('two').versions.collect(&:version).size
+ end
+
+ tests("#all for file returns only versions for that file").returns(versions.last) do
+ @instance.files.get('two').versions.collect(&:version).first
+ end
+ end
+
+ @instance.versions.each(&:destroy)
+ end
+
+end

0 comments on commit 9d02af6

Please sign in to comment.