fog 0.3.15 → 0.3.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/Gemfile.lock +1 -1
  2. data/fog.gemspec +21 -11
  3. data/lib/fog.rb +1 -1
  4. data/lib/fog/core/collection.rb +1 -1
  5. data/lib/fog/rackspace/models/storage/files.rb +8 -8
  6. data/lib/fog/rackspace/requests/storage/get_object.rb +1 -1
  7. data/tests/aws/models/storage/directories_tests.rb +5 -0
  8. data/tests/aws/models/storage/directory_tests.rb +2 -6
  9. data/tests/aws/models/storage/file_tests.rb +5 -0
  10. data/tests/aws/models/storage/files_tests.rb +5 -0
  11. data/tests/google/models/storage/directories_tests.rb +5 -0
  12. data/tests/google/models/storage/directory_tests.rb +5 -0
  13. data/tests/google/models/storage/file_tests.rb +5 -0
  14. data/tests/google/models/storage/files_tests.rb +5 -0
  15. data/tests/helper.rb +10 -1
  16. data/tests/helpers/storage/directories_tests.rb +39 -0
  17. data/tests/helpers/storage/directory_tests.rb +24 -0
  18. data/tests/helpers/storage/file_tests.rb +32 -0
  19. data/tests/helpers/storage/files_tests.rb +47 -0
  20. data/tests/local/models/storage/directories_tests.rb +5 -0
  21. data/tests/local/models/storage/directory_tests.rb +5 -0
  22. data/tests/local/models/storage/file_tests.rb +5 -0
  23. data/tests/local/models/storage/files_tests.rb +5 -0
  24. data/tests/rackspace/models/storage/directories_tests.rb +5 -0
  25. data/tests/rackspace/models/storage/directory_tests.rb +5 -0
  26. data/tests/rackspace/models/storage/file_tests.rb +5 -0
  27. data/tests/rackspace/models/storage/files_tests.rb +5 -0
  28. metadata +22 -12
  29. data/spec/aws/models/storage/directories_spec.rb +0 -49
  30. data/spec/aws/models/storage/directory_spec.rb +0 -113
  31. data/spec/aws/models/storage/file_spec.rb +0 -121
  32. data/spec/aws/models/storage/files_spec.rb +0 -139
  33. data/spec/google/models/storage/directories_spec.rb +0 -49
  34. data/spec/google/models/storage/directory_spec.rb +0 -83
  35. data/spec/google/models/storage/file_spec.rb +0 -121
  36. data/spec/google/models/storage/files_spec.rb +0 -140
  37. data/tests/helpers/model_helper.rb +0 -72
@@ -1,49 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper'
2
-
3
- describe 'Fog::AWS::Storage::Directories' do
4
-
5
- describe "#all" do
6
-
7
- it "should include persisted directories" do
8
- @directory = AWS[:storage].directories.create(:key => 'fogdirectorykey')
9
- AWS[:storage].directories.all.map {|directory| @directory.key}.should include('fogdirectorykey')
10
- @directory.destroy
11
- end
12
-
13
- end
14
-
15
- describe "#create" do
16
-
17
- it "should exist on s3" do
18
- directory = AWS[:storage].directories.create(:key => 'fogdirectorykey')
19
- AWS[:storage].directories.get(directory.key).should_not be_nil
20
- directory.destroy
21
- end
22
-
23
- end
24
-
25
- describe "#get" do
26
-
27
- it "should return a Fog::AWS::Storage::Directory if a matching directory exists" do
28
- directory = AWS[:storage].directories.create(:key => 'fogdirectorykey')
29
- get = AWS[:storage].directories.get('fogdirectorykey')
30
- directory.attributes.should == get.attributes
31
- directory.destroy
32
- end
33
-
34
- it "should return nil if no matching directory exists" do
35
- AWS[:storage].directories.get('fognotadirectory').should be_nil
36
- end
37
-
38
- end
39
-
40
- describe "#reload" do
41
-
42
- it "should reload data" do
43
- directories = AWS[:storage].directories
44
- directories.should == directories.reload
45
- end
46
-
47
- end
48
-
49
- end
@@ -1,113 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper'
2
-
3
- describe 'Fog::AWS::Storage::Directory' do
4
-
5
- describe "#initialize" do
6
-
7
- it "should remap attributes from parser" do
8
- now = Time.now
9
- directory = Fog::AWS::Storage::Directory.new(
10
- 'CreationDate' => now,
11
- 'Name' => 'directorykey'
12
- )
13
- directory.creation_date.should == now
14
- directory.key.should == 'directorykey'
15
- end
16
-
17
- end
18
-
19
- describe "#collection" do
20
-
21
- it "should be the directories the directory is related to" do
22
- directories = AWS[:storage].directories
23
- directories.new.collection.should == directories
24
- end
25
-
26
- end
27
-
28
- describe "#destroy" do
29
-
30
- it "should return true if the directory is deleted" do
31
- directory = AWS[:storage].directories.create(:key => 'fogmodeldirectory')
32
- directory.destroy.should be_true
33
- end
34
-
35
- it "should return false if the directory does not exist" do
36
- directory = AWS[:storage].directories.new(:key => 'fogmodeldirectory')
37
- directory.destroy.should be_false
38
- end
39
-
40
- end
41
-
42
- describe "#location" do
43
-
44
- it "should return the location constraint" do
45
- pending if Fog.mocking?
46
- directory = AWS[:storage].directories.create(:key => 'fogmodeleudirectory', :location => 'EU')
47
- directory.location.should == 'EU'
48
- AWS[:eu_storage].directories.get('fogmodeleudirectory').destroy
49
- end
50
-
51
- end
52
-
53
- describe "#payer" do
54
-
55
- it "should return the request payment value" do
56
- directory = AWS[:storage].directories.create(:key => 'fogmodeldirectory')
57
- directory.payer.should == 'BucketOwner'
58
- directory.destroy.should be_true
59
- end
60
-
61
- end
62
-
63
- describe "#payer=" do
64
-
65
- it "should set the request payment value" do
66
- directory = AWS[:storage].directories.create(:key => 'fogmodeldirectory')
67
- (directory.payer = 'Requester').should == 'Requester'
68
- directory.destroy.should
69
- end
70
-
71
- end
72
-
73
- describe "#reload" do
74
-
75
- before(:each) do
76
- @directory = AWS[:storage].directories.create(:key => 'fogmodeldirectory')
77
- @reloaded = @directory.reload
78
- end
79
-
80
- after(:each) do
81
- @directory.destroy
82
- end
83
-
84
- it "should reset attributes to remote state" do
85
- @directory.attributes.should == @reloaded.attributes
86
- end
87
-
88
- end
89
-
90
- describe "#save" do
91
-
92
- before(:each) do
93
- @directory = AWS[:storage].directories.new(:key => 'fogmodeldirectory')
94
- end
95
-
96
- it "should not exist in directories before save" do
97
- AWS[:storage].directories.all.map {|directory| directory.key}.include?(@directory.key).should be_false
98
- end
99
-
100
- it "should return true when it succeeds" do
101
- @directory.save.should be_true
102
- @directory.destroy
103
- end
104
-
105
- it "should exist in directories after save" do
106
- @directory.save
107
- AWS[:storage].directories.all.map {|directory| directory.key}.include?(@directory.key).should be_true
108
- @directory.destroy
109
- end
110
-
111
- end
112
-
113
- end
@@ -1,121 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper'
2
-
3
- describe 'Fog::AWS::Storage::File' do
4
-
5
- before(:each) do
6
- @directory = AWS[:storage].directories.create(:key => 'fogdirectoryname')
7
- end
8
-
9
- after(:each) do
10
- @directory.destroy
11
- end
12
-
13
- describe "#initialize" do
14
-
15
- it "should remap attributes from parser" do
16
- now = Time.now
17
- directory = Fog::AWS::Storage::File.new(
18
- 'Content-Length' => 10,
19
- 'Content-Type' => 'contenttype',
20
- 'Etag' => 'etag',
21
- 'Key' => 'key',
22
- 'Last-Modified' => now,
23
- 'Size' => 10,
24
- 'StorageClass' => 'storageclass'
25
- )
26
- directory.content_length == 10
27
- directory.content_type.should == 'contenttype'
28
- directory.etag.should == 'etag'
29
- directory.key.should == 'key'
30
- directory.last_modified.should == now
31
- directory.size.should == 10
32
- directory.storage_class.should == 'storageclass'
33
-
34
- directory = Fog::AWS::Storage::File.new(
35
- 'ETag' => 'etag',
36
- 'LastModified' => now
37
- )
38
- directory.etag.should == 'etag'
39
- directory.last_modified.should == now
40
- end
41
-
42
- end
43
-
44
- describe "#directory" do
45
-
46
- it "should be the directory the file is related to" do
47
- @file = @directory.files.new(:key => 'foo')
48
- @file.directory.should == @directory
49
- end
50
-
51
- end
52
-
53
- describe "#copy" do
54
-
55
- it "should return a Fog::AWS::Storage::File with matching attributes" do
56
- other_directory = AWS[:storage].directories.create(:key => 'fogotherdirectoryname')
57
- data = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
58
- file = @directory.files.create(:key => 'fogfilename', :body => data)
59
- other_file = file.copy('fogotherdirectoryname', 'fogotherfilename')
60
- file.reload.attributes.reject{|key,value| [:key, :last_modified].include?(key)}.should == other_file.reload.attributes.reject{|key,value| [:key, :last_modified].include?(key)}
61
- other_file.destroy
62
- file.destroy
63
- other_directory.destroy
64
- end
65
-
66
- end
67
-
68
- describe "#destroy" do
69
-
70
- it "should return true if the file is deleted" do
71
- data = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
72
- file = @directory.files.create(:key => 'fogfilename', :body => data)
73
- file.destroy.should be_true
74
- end
75
-
76
- it "should return true if the file does not exist" do
77
- file = @directory.files.new(:key => 'fogfilename')
78
- file.destroy.should be_true
79
- end
80
-
81
- end
82
-
83
- describe "#reload" do
84
-
85
- it "should reset attributes to remote state" do
86
- data = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
87
- file = @directory.files.create(:key => 'fogfilename', :body => data)
88
- file.last_modified = Time.now
89
- file.reload.attributes.should == file.attributes
90
- file.destroy
91
- end
92
-
93
- end
94
-
95
- describe "#save" do
96
-
97
- it "should return the success value" do
98
- data = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
99
- file = @directory.files.new(:key => 'fogfilename', :body => data)
100
- file.save.should be_true
101
- file.destroy
102
- end
103
-
104
- end
105
-
106
- describe "#url" do
107
-
108
- it "should return a signed expiring url" do
109
- data = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
110
- file = @directory.files.create(:key => 'fogfilename', :body => data)
111
- url = file.url(Time.now + 60 * 10)
112
- url.should include("fogfilename", "Expires")
113
- unless Fog.mocking?
114
- open(url).read.should == File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r').read
115
- end
116
- file.destroy
117
- end
118
-
119
- end
120
-
121
- end
@@ -1,139 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper'
2
-
3
- describe 'Fog::AWS::Storage::Files' do
4
-
5
- before(:each) do
6
- @directory = AWS[:storage].directories.create(:key => "fog#{Time.now.to_f}")
7
- end
8
-
9
- after(:each) do
10
- until @directory.files.reload.empty?
11
- @directory.files.each {|file| file.destroy}
12
- end
13
- @directory.destroy
14
- end
15
-
16
- describe "#initialize" do
17
-
18
- it "should remap attributes from parser" do
19
- files = Fog::AWS::Storage::Files.new(
20
- 'IsTruncated' => true,
21
- 'Marker' => 'marker',
22
- 'MaxKeys' => 1,
23
- 'Prefix' => 'prefix'
24
- )
25
- files.is_truncated.should == true
26
- files.marker.should == 'marker'
27
- files.max_keys.should == 1
28
- files.prefix.should == 'prefix'
29
- end
30
-
31
- end
32
-
33
- describe "#all" do
34
-
35
- it "should return nil if the directory does not exist" do
36
- directory = AWS[:storage].directories.new(:key => 'notadirectory')
37
- directory.files.all.should be_nil
38
- end
39
-
40
- it "should return 1000 files and report truncated" do
41
- 1010.times do |n|
42
- @directory.files.create(:key => "file-#{n}")
43
- end
44
- response = @directory.files.all
45
- response.should have(1000).items
46
- response.is_truncated.should be_true
47
- end
48
-
49
- it "should limit the max_keys to 1000" do
50
- 1010.times do |n|
51
- @directory.files.create(:key => "file-#{n}")
52
- end
53
- response = @directory.files.all(:max_keys => 2000)
54
- response.should have(1000).items
55
- response.max_keys.should == 2000
56
- response.is_truncated.should be_true
57
- end
58
-
59
- end
60
-
61
- describe "#create" do
62
-
63
- it "should exist on s3" do
64
- data = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
65
- file = @directory.files.create(:key => 'fogfilename', :body => data)
66
- @directory.files.get('fogfilename').should_not be_nil
67
- file.destroy
68
- end
69
-
70
- end
71
-
72
- describe "#get" do
73
-
74
- before(:each) do
75
- data = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
76
- @file = @directory.files.create(:key => 'fogfilename', :body => data)
77
- end
78
-
79
- after(:each) do
80
- @file.destroy
81
- end
82
-
83
- it "should return a Fog::AWS::Storage::File with metadata and data" do
84
- @file.reload
85
- @file.body.should_not be_nil
86
- @file.content_length.should_not be_nil
87
- @file.etag.should_not be_nil
88
- @file.last_modified.should_not be_nil
89
- @file.destroy
90
- end
91
-
92
- it "should return chunked data if given a block" do
93
- data = ''
94
- @directory.files.get('fogfilename') do |chunk|
95
- data << chunk
96
- end
97
- data.should == File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r').read
98
- end
99
-
100
- end
101
-
102
- describe "#get_url" do
103
-
104
- it "should return a signed expiring url" do
105
- data = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
106
- file = @directory.files.create(:key => 'fogfilename', :body => data)
107
- url = @directory.files.get_url('fogfilename', Time.now + 60 * 10)
108
- url.should include("fogfilename", "Expires")
109
- unless Fog.mocking?
110
- open(url).read.should == File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r').read
111
- end
112
- file.destroy
113
- end
114
-
115
- end
116
-
117
- describe "#head" do
118
-
119
- it "should return a Fog::AWS::Storage::File with metadata" do
120
- data = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
121
- file = @directory.files.create(:key => 'fogfilename', :body => data)
122
- file = @directory.files.get('fogfilename')
123
- file.content_length.should_not be_nil
124
- file.etag.should_not be_nil
125
- file.last_modified.should_not be_nil
126
- file.destroy
127
- end
128
-
129
- end
130
-
131
- describe "#reload" do
132
-
133
- it "should reload data" do
134
- @directory.files.reload.should == @directory.files
135
- end
136
-
137
- end
138
-
139
- end
@@ -1,49 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper'
2
-
3
- describe 'Fog::Google::Storage::Directories' do
4
-
5
- describe "#all" do
6
-
7
- it "should include persisted directories" do
8
- @directory = Google[:storage].directories.create(:key => 'fogdirectorykey')
9
- Google[:storage].directories.all.map {|directory| @directory.key}.should include('fogdirectorykey')
10
- @directory.destroy
11
- end
12
-
13
- end
14
-
15
- describe "#create" do
16
-
17
- it "should exist on google storage" do
18
- directory = Google[:storage].directories.create(:key => 'fogdirectorykey')
19
- Google[:storage].directories.get(directory.key).should_not be_nil
20
- directory.destroy
21
- end
22
-
23
- end
24
-
25
- describe "#get" do
26
-
27
- it "should return a Fog::Google::Storage::Directory if a matching directory exists" do
28
- directory = Google[:storage].directories.create(:key => 'fogdirectorykey')
29
- get = Google[:storage].directories.get('fogdirectorykey')
30
- directory.attributes.should == get.attributes
31
- directory.destroy
32
- end
33
-
34
- it "should return nil if no matching directory exists" do
35
- Google[:storage].directories.get('fognotadirectory').should be_nil
36
- end
37
-
38
- end
39
-
40
- describe "#reload" do
41
-
42
- it "should reload data" do
43
- directories = Google[:storage].directories
44
- directories.should == directories.reload
45
- end
46
-
47
- end
48
-
49
- end