remote_files 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/remote_files.rb +10 -4
- data/lib/remote_files/configuration.rb +0 -2
- data/lib/remote_files/fog_store.rb +0 -1
- data/lib/remote_files/mock_store.rb +0 -2
- data/lib/remote_files/version.rb +1 -1
- metadata +24 -26
- data/test/configuration_test.rb +0 -283
- data/test/file_store_test.rb +0 -114
- data/test/file_test.rb +0 -170
- data/test/fog_store_test.rb +0 -196
- data/test/memory_store_test.rb +0 -104
- data/test/remote_files_test.rb +0 -20
- data/test/resque_job_test.rb +0 -75
- data/test/test_helper.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d5fa511b2480edeb476a70bf2f9897b309f6224
|
4
|
+
data.tar.gz: a23623f2c720d68b9e53c9a5a842506c8ac98c3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d82764b13f50ff1a92942eb06fa2dea43b073e791c59a0c41da701d679aff6891a9577d149435b544fa44f8278cf0cb91f6dd4273466929e3d4a627a2de33085
|
7
|
+
data.tar.gz: 440e8b116677e887b3bfcfda1bb5b80ef96b356ab306fb9d64da3485414652a53822ebe0c05c2493ee53f9028cb9707b7f8c338e1956b80a8077d4ef83ab5b72
|
data/lib/remote_files.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
-
require 'remote_files/version'
|
2
|
-
require 'remote_files/configuration'
|
3
|
-
require 'remote_files/file'
|
4
|
-
|
5
1
|
module RemoteFiles
|
2
|
+
autoload :AbstractStore, 'remote_files/abstract_store'
|
3
|
+
autoload :Configuration, 'remote_files/configuration'
|
4
|
+
autoload :File, 'remote_files/file'
|
5
|
+
autoload :FileStore, 'remote_files/file_store'
|
6
|
+
autoload :FogStore, 'remote_files/fog_store'
|
7
|
+
autoload :MemoryStore, 'remote_files/memory_store'
|
8
|
+
autoload :MockStore, 'remote_files/mock_store'
|
9
|
+
autoload :ResqueJob, 'remote_files/resque_job'
|
10
|
+
autoload :VERSION, 'remote_files/version'
|
11
|
+
|
6
12
|
class Error < StandardError; end
|
7
13
|
class NotFoundError < Error; end
|
8
14
|
|
data/lib/remote_files/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remote_files
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mick Staugaard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog
|
@@ -42,16 +42,30 @@ dependencies:
|
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest-rg
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: mocha
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,6 +102,8 @@ executables: []
|
|
88
102
|
extensions: []
|
89
103
|
extra_rdoc_files: []
|
90
104
|
files:
|
105
|
+
- README.md
|
106
|
+
- lib/remote_files.rb
|
91
107
|
- lib/remote_files/abstract_store.rb
|
92
108
|
- lib/remote_files/configuration.rb
|
93
109
|
- lib/remote_files/file.rb
|
@@ -97,16 +113,6 @@ files:
|
|
97
113
|
- lib/remote_files/mock_store.rb
|
98
114
|
- lib/remote_files/resque_job.rb
|
99
115
|
- lib/remote_files/version.rb
|
100
|
-
- lib/remote_files.rb
|
101
|
-
- test/configuration_test.rb
|
102
|
-
- test/file_store_test.rb
|
103
|
-
- test/file_test.rb
|
104
|
-
- test/fog_store_test.rb
|
105
|
-
- test/memory_store_test.rb
|
106
|
-
- test/remote_files_test.rb
|
107
|
-
- test/resque_job_test.rb
|
108
|
-
- test/test_helper.rb
|
109
|
-
- README.md
|
110
116
|
homepage: https://github.com/zendesk/remote_files
|
111
117
|
licenses:
|
112
118
|
- Apache License Version 2.0
|
@@ -127,18 +133,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
133
|
version: '0'
|
128
134
|
requirements: []
|
129
135
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.0.
|
136
|
+
rubygems_version: 2.0.14
|
131
137
|
signing_key:
|
132
138
|
specification_version: 4
|
133
139
|
summary: The purpose of the library is to implement a simple interface for uploading
|
134
140
|
files to multiple backends and to keep the backends in sync, so that your app will
|
135
141
|
keep working when one backend is down.
|
136
|
-
test_files:
|
137
|
-
- test/configuration_test.rb
|
138
|
-
- test/file_store_test.rb
|
139
|
-
- test/file_test.rb
|
140
|
-
- test/fog_store_test.rb
|
141
|
-
- test/memory_store_test.rb
|
142
|
-
- test/remote_files_test.rb
|
143
|
-
- test/resque_job_test.rb
|
144
|
-
- test/test_helper.rb
|
142
|
+
test_files: []
|
data/test/configuration_test.rb
DELETED
@@ -1,283 +0,0 @@
|
|
1
|
-
require 'logger'
|
2
|
-
require_relative 'test_helper'
|
3
|
-
require 'remote_files/mock_store'
|
4
|
-
|
5
|
-
describe RemoteFiles::Configuration do
|
6
|
-
before do
|
7
|
-
@configuration = RemoteFiles.configure(:test)
|
8
|
-
@file = RemoteFiles::File.new('file', :configuration => :test, :content => 'content', :content_type => 'text/plain')
|
9
|
-
@mock_store1 = @configuration.add_store(:mock1, :class => RemoteFiles::MockStore)
|
10
|
-
@mock_store2 = @configuration.add_store(:mock2, :class => RemoteFiles::MockStore)
|
11
|
-
end
|
12
|
-
|
13
|
-
describe '#logger' do
|
14
|
-
it 'defaults to RemoteFiles.logger' do
|
15
|
-
logger = Logger.new($stdout)
|
16
|
-
RemoteFiles.logger = logger
|
17
|
-
configuration_logger = @configuration.logger
|
18
|
-
RemoteFiles.logger = nil
|
19
|
-
|
20
|
-
configuration_logger.must_equal logger
|
21
|
-
|
22
|
-
new_logger = Logger.new($stdout)
|
23
|
-
|
24
|
-
@configuration.logger = new_logger
|
25
|
-
@configuration.logger.must_equal new_logger
|
26
|
-
|
27
|
-
@configuration.logger = nil
|
28
|
-
@configuration.logger.must_be_nil
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe '::add_store' do
|
33
|
-
describe 'when adding a non-primary store' do
|
34
|
-
before { @non_primary_store = @configuration.add_store(:primary) }
|
35
|
-
|
36
|
-
it 'should add it to the tail of the list of stores' do
|
37
|
-
@configuration.stores.must_equal([@mock_store1, @mock_store2, @non_primary_store])
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe 'when adding a promary store' do
|
42
|
-
before { @primary_store = @configuration.add_store(:primary, :primary => true) }
|
43
|
-
|
44
|
-
it 'should add it to the head of the list of stores' do
|
45
|
-
@configuration.stores.must_equal([@primary_store, @mock_store1, @mock_store2])
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe '::primary_store' do
|
51
|
-
before do
|
52
|
-
@primary_store1 = @configuration.add_store(:primary1, :primary => true)
|
53
|
-
@primary_store2 = @configuration.add_store(:primary2, :primary => true)
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'should return the head of the list of stores' do
|
57
|
-
@configuration.primary_store.must_equal(@primary_store2)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe '::lookup_store' do
|
62
|
-
before do
|
63
|
-
@primary_store = @configuration.add_store(:primary, :primary => true)
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'should find the store my identifier' do
|
67
|
-
@configuration.lookup_store(:mock1).must_equal(@mock_store1)
|
68
|
-
@configuration.lookup_store(:mock2).must_equal(@mock_store2)
|
69
|
-
@configuration.lookup_store(:primary).must_equal(@primary_store)
|
70
|
-
@configuration.lookup_store(:unknown).must_be_nil
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe '::store_once!' do
|
75
|
-
|
76
|
-
describe 'when the first store succeeds' do
|
77
|
-
before { @configuration.store_once!(@file) }
|
78
|
-
|
79
|
-
it 'should only store the file in the first store' do
|
80
|
-
@mock_store1.data['file'].must_equal(:content => 'content', :content_type => 'text/plain')
|
81
|
-
@mock_store2.data['file'].must_be_nil
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
describe 'when the first store fails' do
|
86
|
-
before do
|
87
|
-
@log = StringIO.new
|
88
|
-
@file.logger = Logger.new(@log)
|
89
|
-
@mock_store1.expects(:store!).with(@file).raises(RemoteFiles::Error)
|
90
|
-
@configuration.store_once!(@file)
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'should only store the file in the second store' do
|
94
|
-
@mock_store1.data['file'].must_be_nil
|
95
|
-
@mock_store2.data['file'].must_equal(:content => 'content', :content_type => 'text/plain')
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'logs that the first store failed' do
|
99
|
-
@log.string.must_match /RemoteFiles::Error/
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
describe 'when alls stores fail' do
|
104
|
-
before do
|
105
|
-
@mock_store1.expects(:store!).with(@file).raises(RemoteFiles::Error)
|
106
|
-
@mock_store2.expects(:store!).with(@file).raises(RemoteFiles::Error)
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'should raise a RemoteFiles::Error' do
|
110
|
-
proc { @configuration.store_once!(@file) }.must_raise(RemoteFiles::Error)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
describe '::store!' do
|
116
|
-
describe 'when the file is already stored in some stores' do
|
117
|
-
before { @file.stored_in.replace([@mock_store1.identifier]) }
|
118
|
-
|
119
|
-
it 'should not store the file' do
|
120
|
-
@configuration.expects(:store_once!).never
|
121
|
-
@configuration.store!(@file)
|
122
|
-
end
|
123
|
-
|
124
|
-
it 'should synchronize the stores' do
|
125
|
-
RemoteFiles.expects(:synchronize_stores).with(@file)
|
126
|
-
@configuration.store!(@file)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
describe 'when the file is stored in all stores' do
|
131
|
-
before { @file.stored_in.replace([@mock_store1.identifier, @mock_store2.identifier]) }
|
132
|
-
|
133
|
-
it 'should not store the file' do
|
134
|
-
@configuration.expects(:store_once!).never
|
135
|
-
@configuration.store!(@file)
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'should not synchronize the stores' do
|
139
|
-
RemoteFiles.expects(:synchronize_stores).never
|
140
|
-
@configuration.store!(@file)
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|
144
|
-
|
145
|
-
describe 'when the file is not stored anywhere' do
|
146
|
-
before { @file.stored_in.replace([]) }
|
147
|
-
|
148
|
-
it 'should store the file once' do
|
149
|
-
@file.configuration.expects(:store_once!).with(@file)
|
150
|
-
@configuration.store!(@file)
|
151
|
-
end
|
152
|
-
|
153
|
-
it 'should synchronize the stores' do
|
154
|
-
RemoteFiles.expects(:synchronize_stores).with(@file)
|
155
|
-
@configuration.store!(@file)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
describe '::delete_now!' do
|
161
|
-
before do
|
162
|
-
@file.stored_in.replace([:mock1, :mock2])
|
163
|
-
end
|
164
|
-
|
165
|
-
describe 'when the file is in all of stores' do
|
166
|
-
before do
|
167
|
-
@mock_store1.data[@file.identifier] = {:content_type => 'text/plain', :content => 'content'}
|
168
|
-
@mock_store2.data[@file.identifier] = {:content_type => 'text/plain', :content => 'content'}
|
169
|
-
end
|
170
|
-
|
171
|
-
it 'should delete the file from all the stores' do
|
172
|
-
@configuration.delete_now!(@file)
|
173
|
-
@mock_store1.data.has_key?(@file.identifier).must_equal false
|
174
|
-
@mock_store2.data.has_key?(@file.identifier).must_equal false
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
describe 'when the file is in some of stores' do
|
179
|
-
before do
|
180
|
-
@mock_store2.data[@file.identifier] = {:content_type => 'text/plain', :content => 'content'}
|
181
|
-
end
|
182
|
-
|
183
|
-
it 'should delete the file from all the stores' do
|
184
|
-
@configuration.delete_now!(@file)
|
185
|
-
@mock_store1.data.has_key?(@file.identifier).must_equal false
|
186
|
-
@mock_store2.data.has_key?(@file.identifier).must_equal false
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
describe 'when the file is in none of stores' do
|
191
|
-
it 'raises a NotFoundError' do
|
192
|
-
lambda { @configuration.delete_now!(@file) }.must_raise(RemoteFiles::NotFoundError)
|
193
|
-
@mock_store1.data.has_key?(@file.identifier).must_equal false
|
194
|
-
@mock_store2.data.has_key?(@file.identifier).must_equal false
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
describe '::delete!' do
|
200
|
-
describe 'when no handler has been defined' do
|
201
|
-
before do
|
202
|
-
RemoteFiles.instance_variable_set(:@delete_file, nil)
|
203
|
-
end
|
204
|
-
|
205
|
-
it 'deletes the file' do
|
206
|
-
@file.expects(:delete_now!)
|
207
|
-
@configuration.delete!(@file)
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
describe 'when a handler is defined' do
|
212
|
-
before do
|
213
|
-
@deleted_files = []
|
214
|
-
RemoteFiles.delete_file { |file| @deleted_files << file }
|
215
|
-
end
|
216
|
-
|
217
|
-
it 'should call the handler' do
|
218
|
-
@configuration.delete!(@file)
|
219
|
-
@deleted_files.must_equal [@file]
|
220
|
-
end
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
describe '::synchronize!' do
|
225
|
-
describe 'when the file is not stored anywhere' do
|
226
|
-
before { @file.stored_in.replace([]) }
|
227
|
-
|
228
|
-
it 'should store the file on all stores' do
|
229
|
-
@mock_store1.expects(:store!).returns(true)
|
230
|
-
@mock_store2.expects(:store!).returns(true)
|
231
|
-
|
232
|
-
@configuration.synchronize!(@file)
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
|
-
describe 'when the file is stored in some stores' do
|
237
|
-
before { @file.stored_in.replace([@mock_store1.identifier]) }
|
238
|
-
|
239
|
-
it 'should store the file in the remaining stores' do
|
240
|
-
@mock_store1.expects(:store!).never
|
241
|
-
@mock_store2.expects(:store!).with(@file).returns(true)
|
242
|
-
|
243
|
-
@configuration.synchronize!(@file)
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
describe 'when the file is stored everywhere' do
|
248
|
-
before { @file.stored_in.replace([@mock_store1.identifier, @mock_store2.identifier]) }
|
249
|
-
|
250
|
-
it 'should not do anything' do
|
251
|
-
@mock_store1.expects(:store!).never
|
252
|
-
@mock_store2.expects(:store!).never
|
253
|
-
|
254
|
-
@configuration.synchronize!(@file)
|
255
|
-
end
|
256
|
-
end
|
257
|
-
end
|
258
|
-
|
259
|
-
describe '#file_from_url' do
|
260
|
-
before do
|
261
|
-
@file = @configuration.file_from_url('memory://mock2/foo%40bar', :foo => :bar)
|
262
|
-
assert @file
|
263
|
-
end
|
264
|
-
|
265
|
-
it 'should unescape the identifier' do
|
266
|
-
@file.identifier.must_equal "foo@bar"
|
267
|
-
end
|
268
|
-
|
269
|
-
it 'should return a file from this configuration' do
|
270
|
-
@file.configuration.must_equal @configuration
|
271
|
-
end
|
272
|
-
|
273
|
-
it 'should pass on options' do
|
274
|
-
@file.options[:foo].must_equal :bar
|
275
|
-
end
|
276
|
-
|
277
|
-
it 'returns nil if the url does not match a store' do
|
278
|
-
file = @configuration.file_from_url('http://foo/bar', :foo => :bar)
|
279
|
-
file.must_be_nil
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
end
|
data/test/file_store_test.rb
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
require 'remote_files/file_store'
|
3
|
-
|
4
|
-
describe RemoteFiles::FileStore do
|
5
|
-
before do
|
6
|
-
@directory = Pathname.new(File.dirname(__FILE__)) + '../tmp'
|
7
|
-
|
8
|
-
@store = RemoteFiles::FileStore.new(:file)
|
9
|
-
@store[:directory] = @directory
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '#store!' do
|
13
|
-
before do
|
14
|
-
@file = RemoteFiles::File.new('foo/identifier', :content_type => 'text/plain', :content => content)
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.it_should_store_file
|
18
|
-
it 'should store the file on disk' do
|
19
|
-
@store.store!(@file)
|
20
|
-
|
21
|
-
file_path = @directory + 'foo/identifier'
|
22
|
-
file_path.exist?
|
23
|
-
|
24
|
-
assert_equal 'content', file_path.read
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "content = string" do
|
29
|
-
let(:content) { "content" }
|
30
|
-
it_should_store_file
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "content = stringio" do
|
34
|
-
let(:content) { StringIO.new("content") }
|
35
|
-
it_should_store_file
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "content = io" do
|
39
|
-
let(:content) do
|
40
|
-
mock('IO').tap do |io|
|
41
|
-
io.stubs(:read).returns("content").then.returns(nil)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
it_should_store_file
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe '#retrieve!' do
|
50
|
-
it 'should return a RemoteFiles::File when found' do
|
51
|
-
(@store.directory + 'identifier').open('w') do |f|
|
52
|
-
f.write('content')
|
53
|
-
end
|
54
|
-
|
55
|
-
file = @store.retrieve!('identifier')
|
56
|
-
|
57
|
-
file.must_be_instance_of(RemoteFiles::File)
|
58
|
-
file.content.must_equal('content')
|
59
|
-
# file.content_type.must_equal('text/plain')
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'should raise a RemoteFiles::NotFoundError when not found' do
|
63
|
-
(@store.directory + 'identifier').delete rescue nil
|
64
|
-
proc { @store.retrieve!('identifier') }.must_raise(RemoteFiles::NotFoundError)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe '#url' do
|
69
|
-
it 'should return a file url' do
|
70
|
-
@store.url('identifier').must_equal("file://localhost#{@directory}/identifier")
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe '#file_from_url' do
|
75
|
-
it 'should create a file if the directory matches' do
|
76
|
-
file = @store.file_from_url("file://localhost#{@directory}/identifier")
|
77
|
-
assert file
|
78
|
-
assert_equal 'identifier', file.identifier
|
79
|
-
|
80
|
-
file = @store.file_from_url("file://localhost#{@directory}_other/identifier")
|
81
|
-
assert !file
|
82
|
-
|
83
|
-
file = @store.file_from_url('https://s3.amazonaws.com/mem/identifier')
|
84
|
-
assert !file
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe '#delete!' do
|
89
|
-
before do
|
90
|
-
(@store.directory + 'identifier').open('w') do |f|
|
91
|
-
f.write('content')
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'raises a NotFoundError if the file does not exist' do
|
96
|
-
lambda { @store.delete!('unknown') }.must_raise(RemoteFiles::NotFoundError)
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'should destroy the file' do
|
100
|
-
assert (@store.directory + 'identifier').exist?
|
101
|
-
|
102
|
-
@store.delete!('identifier')
|
103
|
-
|
104
|
-
assert !(@store.directory + 'identifier').exist?
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
describe '#directory_name' do
|
109
|
-
it 'returns the name of the directory' do
|
110
|
-
@store.directory_name.must_equal @directory.to_s
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
data/test/file_test.rb
DELETED
@@ -1,170 +0,0 @@
|
|
1
|
-
require 'logger'
|
2
|
-
require_relative 'test_helper'
|
3
|
-
|
4
|
-
describe RemoteFiles::File do
|
5
|
-
before do
|
6
|
-
@s3 = RemoteFiles.add_store(:s3, :class => RemoteFiles::MockStore, :primary => true)
|
7
|
-
@cf = RemoteFiles.add_store(:cf, :class => RemoteFiles::MockStore)
|
8
|
-
|
9
|
-
@file = RemoteFiles::File.new('identifier')
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '#logger' do
|
13
|
-
it 'defaults to the configuration logger' do
|
14
|
-
configuration_logger = Logger.new($stdout)
|
15
|
-
configuration = RemoteFiles.configure(:test)
|
16
|
-
configuration.logger = configuration_logger
|
17
|
-
|
18
|
-
file = RemoteFiles::File.new('identifier', :configuration => :test)
|
19
|
-
file.logger.must_equal configuration_logger
|
20
|
-
|
21
|
-
new_logger = Logger.new($stdout)
|
22
|
-
file.logger = new_logger
|
23
|
-
file.logger.must_equal new_logger
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'is settable at initialization' do
|
27
|
-
logger = Logger.new($stdout)
|
28
|
-
file = RemoteFiles::File.new('identifier', :logger => logger)
|
29
|
-
file.logger.must_equal logger
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '#stored?' do
|
34
|
-
it 'should return true if the file is stored anywhere' do
|
35
|
-
@file.stored_in << :s3
|
36
|
-
@file.stored?.must_equal(true)
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should return false if the file is not stored anywhere' do
|
40
|
-
@file.stored_in.clear
|
41
|
-
@file.stored?.must_equal(false)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '#stored_everywhere?' do
|
46
|
-
it 'should return false if the file is not stored anywhere' do
|
47
|
-
@file.stored_in.clear
|
48
|
-
@file.stored_everywhere?.must_equal(false)
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'should return false if the file only is stored in some of the stores' do
|
52
|
-
@file.stored_in.replace([:s3])
|
53
|
-
@file.stored_everywhere?.must_equal(false)
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'should return true if the file is stored in all stores' do
|
57
|
-
@file.stored_in.replace([:s3, :cf])
|
58
|
-
@file.stored_everywhere?.must_equal(true)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe '#stores' do
|
63
|
-
it 'should give an array of stores where the file is stored' do
|
64
|
-
@file.stored_in.replace([:s3])
|
65
|
-
@file.stores.must_equal([@s3])
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe '#missing_stores' do
|
70
|
-
it 'should give an array of stores where the file is not stored' do
|
71
|
-
@file.stored_in.replace([:s3])
|
72
|
-
@file.missing_stores.must_equal([@cf])
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe '#url' do
|
77
|
-
before do
|
78
|
-
@s3.stubs(:url).returns('s3_url')
|
79
|
-
@cf.stubs(:url).returns('cf_url')
|
80
|
-
end
|
81
|
-
|
82
|
-
describe 'with no arguments' do
|
83
|
-
it 'should return the url on the primary store' do
|
84
|
-
@file.url.must_equal('s3_url')
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe 'with a store identifier' do
|
89
|
-
it 'should return the url from that store' do
|
90
|
-
@file.url(:cf).must_equal('cf_url')
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe '#current_url' do
|
96
|
-
it 'should return the url from the first store where the file is currently stored' do
|
97
|
-
@s3.stubs(:url).returns('s3_url')
|
98
|
-
@cf.stubs(:url).returns('cf_url')
|
99
|
-
|
100
|
-
@file.stored_in.replace([:s3])
|
101
|
-
@file.current_url.must_equal('s3_url')
|
102
|
-
|
103
|
-
@file.stored_in.replace([:cf])
|
104
|
-
@file.current_url.must_equal('cf_url')
|
105
|
-
|
106
|
-
@file.stored_in.replace([:cf, :s3])
|
107
|
-
@file.current_url.must_equal('s3_url')
|
108
|
-
|
109
|
-
@file.stored_in.replace([])
|
110
|
-
@file.current_url.must_be_nil
|
111
|
-
end
|
112
|
-
|
113
|
-
describe '::from_url' do
|
114
|
-
it 'should return a file from the first store that matches' do
|
115
|
-
url = 'http://something'
|
116
|
-
@cf.expects(:file_from_url).with(url, :configuration => :default).returns(@file)
|
117
|
-
assert_equal @file, RemoteFiles::File.from_url(url)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
describe '#delete_now!' do
|
123
|
-
it 'asks the configuration to delete the file' do
|
124
|
-
@file.configuration.expects(:delete_now!).with(@file).returns(true)
|
125
|
-
@file.delete_now!
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
describe '#delete!' do
|
130
|
-
it 'asks the configuration to delete the file' do
|
131
|
-
@file.configuration.expects(:delete!).with(@file).returns(true)
|
132
|
-
@file.delete!
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
describe '#retrieve!' do
|
137
|
-
before do
|
138
|
-
@file_with_content = RemoteFiles::File.new('identifier', :content => 'content', :content_type => 'content_type')
|
139
|
-
|
140
|
-
@store = stub
|
141
|
-
@file.stubs(:stores).returns([@store])
|
142
|
-
end
|
143
|
-
|
144
|
-
describe 'when the file is found' do
|
145
|
-
before do
|
146
|
-
@store.expects(:retrieve!).returns(@file_with_content)
|
147
|
-
end
|
148
|
-
|
149
|
-
it 'fills in the content and content_type' do
|
150
|
-
@file.content.must_be_nil
|
151
|
-
@file.content_type.must_be_nil
|
152
|
-
|
153
|
-
@file.retrieve!
|
154
|
-
|
155
|
-
@file.content.must_equal 'content'
|
156
|
-
@file.content_type.must_equal 'content_type'
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
describe 'when the file is not found' do
|
161
|
-
before do
|
162
|
-
@store.expects(:retrieve!).returns(nil)
|
163
|
-
end
|
164
|
-
|
165
|
-
it 'raises a NotFoundError' do
|
166
|
-
proc { @file.retrieve! }.must_raise(RemoteFiles::NotFoundError)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
data/test/fog_store_test.rb
DELETED
@@ -1,196 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
describe RemoteFiles::FogStore do
|
4
|
-
before do
|
5
|
-
@connection = Fog::Storage.new({
|
6
|
-
:provider => 'AWS',
|
7
|
-
:aws_access_key_id => 'access_key_id',
|
8
|
-
:aws_secret_access_key => 'secret_access_key'
|
9
|
-
})
|
10
|
-
|
11
|
-
@store = RemoteFiles::FogStore.new(:fog)
|
12
|
-
@store[:provider] = 'AWS'
|
13
|
-
@store[:aws_access_key_id] = 'access_key_id'
|
14
|
-
@store[:aws_secret_access_key] = 'secret_access_key'
|
15
|
-
@store[:directory] = 'directory'
|
16
|
-
@store[:public] = true
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'configuration' do
|
20
|
-
it 'should configure a fog connection' do
|
21
|
-
connection = @store.connection
|
22
|
-
|
23
|
-
connection.must_be_instance_of(Fog::Storage::AWS::Mock)
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should configure directory' do
|
27
|
-
directory = @store.directory
|
28
|
-
|
29
|
-
directory.must_be_instance_of(Fog::Storage::AWS::Directory)
|
30
|
-
|
31
|
-
directory.key.must_equal('directory')
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should create the remote directory if it does not exist' do
|
35
|
-
assert_nil @connection.directories.get('directory')
|
36
|
-
|
37
|
-
directory = @store.directory
|
38
|
-
assert directory
|
39
|
-
assert_equal 'directory', directory.key
|
40
|
-
|
41
|
-
assert @connection.directories.get('directory')
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '#store!' do
|
46
|
-
before do
|
47
|
-
@file = RemoteFiles::File.new('identifier', :content_type => 'text/plain', :content => 'content')
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'should store the file in the directory' do
|
51
|
-
@store.store!(@file)
|
52
|
-
|
53
|
-
fog_file = @store.directory.files.get('identifier')
|
54
|
-
|
55
|
-
fog_file.must_be_instance_of(Fog::Storage::AWS::File)
|
56
|
-
fog_file.content_type.must_equal('text/plain')
|
57
|
-
fog_file.body.must_equal('content')
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'should raise a RemoteFiles::Error when an error happens' do
|
61
|
-
@store.directory.destroy
|
62
|
-
proc { @store.store!(@file) }.must_raise(RemoteFiles::Error)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe '#retrieve!' do
|
67
|
-
it 'should return a RemoteFiles::File when found' do
|
68
|
-
@store.directory.files.create(
|
69
|
-
:body => 'content',
|
70
|
-
:content_type => 'text/plain',
|
71
|
-
:key => 'identifier'
|
72
|
-
)
|
73
|
-
|
74
|
-
file = @store.retrieve!('identifier')
|
75
|
-
|
76
|
-
file.must_be_instance_of(RemoteFiles::File)
|
77
|
-
file.content.must_equal('content')
|
78
|
-
file.content_type.must_equal('text/plain')
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'should raise a RemoteFiles::NotFoundError when not found' do
|
82
|
-
proc { @store.retrieve!('identifier') }.must_raise(RemoteFiles::NotFoundError)
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'should raise a RemoteFiles::Error when error' do
|
86
|
-
@store.directory.destroy
|
87
|
-
proc { @store.retrieve!('identifier') }.must_raise(RemoteFiles::Error)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe '#url' do
|
92
|
-
describe 'for S3 connections' do
|
93
|
-
before { @store[:provider] = 'AWS' }
|
94
|
-
|
95
|
-
it 'should return an S3 url' do
|
96
|
-
@store.url('identifier').must_equal('https://s3.amazonaws.com/directory/identifier')
|
97
|
-
end
|
98
|
-
|
99
|
-
describe 'in a different region' do
|
100
|
-
before { @store.options[:region] = 'us-west-1' }
|
101
|
-
|
102
|
-
it 'should return an S3 url' do
|
103
|
-
@store.url('identifier').must_equal('https://s3-us-west-1.amazonaws.com/directory/identifier')
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
describe 'for CloudFiles connections' do
|
109
|
-
before { @store[:provider] = 'Rackspace' }
|
110
|
-
|
111
|
-
it 'should return a CloudFiles url' do
|
112
|
-
@store.url('identifier').must_equal('https://storage.cloudfiles.com/directory/identifier')
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
describe 'for other connections' do
|
117
|
-
before { @store[:provider] = 'Google' }
|
118
|
-
|
119
|
-
it 'should raise' do
|
120
|
-
proc { @store.url('identifier') }.must_raise(RuntimeError)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
describe '#file_from_url' do
|
126
|
-
describe 'for an S3 store' do
|
127
|
-
before { @store[:provider] = 'AWS' }
|
128
|
-
|
129
|
-
it 'should create a file if the bucket matches' do
|
130
|
-
file = @store.file_from_url('http://s3-eu-west-1.amazonaws.com/directory/key/on/cloud.txt')
|
131
|
-
assert file
|
132
|
-
assert_equal 'key/on/cloud.txt', file.identifier
|
133
|
-
|
134
|
-
file = @store.file_from_url('http://s3-eu-west-1.amazonaws.com/other_bucket/key/on/cloud.txt')
|
135
|
-
assert !file
|
136
|
-
|
137
|
-
file = @store.file_from_url('http://storage.cloudfiles.com/directory/key/on/cloud.txt')
|
138
|
-
assert !file
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
describe 'for a cloudfiles store' do
|
143
|
-
before { @store[:provider] = 'Rackspace' }
|
144
|
-
|
145
|
-
it 'should create a file if the container matches' do
|
146
|
-
file = @store.file_from_url('http://storage.cloudfiles.com/directory/key/on/cloud.txt')
|
147
|
-
assert file
|
148
|
-
assert_equal 'key/on/cloud.txt', file.identifier
|
149
|
-
|
150
|
-
file = @store.file_from_url('http://storage.cloudfiles.com/other_container/key/on/cloud.txt')
|
151
|
-
assert !file
|
152
|
-
|
153
|
-
file = @store.file_from_url('http://s3-eu-west-1.amazonaws.com/directory/key/on/cloud.txt')
|
154
|
-
assert !file
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
describe 'for other stores' do
|
159
|
-
before { @store[:provider] = 'Google' }
|
160
|
-
|
161
|
-
it 'should raise a RuntimeError' do
|
162
|
-
proc { @store.file_from_url('http://s3-eu-west-1.amazonaws.com/directory/key/on/cloud.txt') }.must_raise(RuntimeError)
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
describe '#delete!' do
|
168
|
-
before do
|
169
|
-
@store.directory.files.create(
|
170
|
-
:body => 'content',
|
171
|
-
:content_type => 'text/plain',
|
172
|
-
:key => 'identifier'
|
173
|
-
)
|
174
|
-
end
|
175
|
-
|
176
|
-
it 'raises a NotFoundError if the file does not exist' do
|
177
|
-
@store.directory.key = 'unknown' # to force an exception out of the fog
|
178
|
-
lambda { @store.delete!('unknown') }.must_raise(RemoteFiles::NotFoundError)
|
179
|
-
end
|
180
|
-
|
181
|
-
it 'should destroy the file' do
|
182
|
-
assert @store.directory.files.get('identifier')
|
183
|
-
|
184
|
-
@store.delete!('identifier')
|
185
|
-
|
186
|
-
assert !@store.directory.files.get('identifier')
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
describe '#directory_name' do
|
191
|
-
it 'returns the name of the directory' do
|
192
|
-
@store.directory_name.must_equal 'directory'
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
end
|
data/test/memory_store_test.rb
DELETED
@@ -1,104 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
require 'remote_files/memory_store'
|
3
|
-
|
4
|
-
describe RemoteFiles::MemoryStore do
|
5
|
-
before do
|
6
|
-
@store = RemoteFiles::MemoryStore.new(:mem)
|
7
|
-
end
|
8
|
-
|
9
|
-
describe '#store!' do
|
10
|
-
before do
|
11
|
-
@file = RemoteFiles::File.new('identifier', :content_type => 'text/plain', :content => content)
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.it_should_store_file
|
15
|
-
it 'should store the file in the memory' do
|
16
|
-
@store.store!(@file)
|
17
|
-
|
18
|
-
assert_equal({:content_type => 'text/plain', :content => 'content'}, @store.data['identifier'])
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "content = string" do
|
23
|
-
let(:content) { "content" }
|
24
|
-
it_should_store_file
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "content = stringio" do
|
28
|
-
let(:content) { StringIO.new("content") }
|
29
|
-
it_should_store_file
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "content = io" do
|
33
|
-
let(:content) do
|
34
|
-
mock('IO').tap do |io|
|
35
|
-
io.stubs(:read).returns("content").then.returns(nil)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
it_should_store_file
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe '#retrieve!' do
|
44
|
-
it 'should return a RemoteFiles::File when found' do
|
45
|
-
@store.data['identifier'] = {:content_type => 'text/plain', :content => 'content'}
|
46
|
-
|
47
|
-
file = @store.retrieve!('identifier')
|
48
|
-
|
49
|
-
file.must_be_instance_of(RemoteFiles::File)
|
50
|
-
file.content.must_equal('content')
|
51
|
-
file.content_type.must_equal('text/plain')
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'should raise a RemoteFiles::NotFoundError when not found' do
|
55
|
-
proc { @store.retrieve!('identifier') }.must_raise(RemoteFiles::NotFoundError)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe '#url' do
|
60
|
-
it 'should return a fake memory url' do
|
61
|
-
@store.url('identifier').must_equal('memory://mem/identifier')
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe '#file_from_url' do
|
66
|
-
it 'should create a file if the store identifier matches' do
|
67
|
-
file = @store.file_from_url('memory://mem/identifier')
|
68
|
-
assert file
|
69
|
-
assert_equal 'identifier', file.identifier
|
70
|
-
|
71
|
-
file = @store.file_from_url('memory://other_store/identifier')
|
72
|
-
assert !file
|
73
|
-
|
74
|
-
file = @store.file_from_url('https://s3.amazonaws.com/mem/identifier')
|
75
|
-
assert !file
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe '#delete!' do
|
80
|
-
before do
|
81
|
-
@store.data['identifier'] = {:content_type => 'text/plain', :content => 'content'}
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'raises a NotFoundError if the file does not exist' do
|
85
|
-
lambda { @store.delete!('unknown') }.must_raise(RemoteFiles::NotFoundError)
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'should destroy the file' do
|
89
|
-
assert @store.data['identifier']
|
90
|
-
|
91
|
-
@store.delete!('identifier')
|
92
|
-
|
93
|
-
assert !@store.data['identifier']
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
|
98
|
-
describe '#directory_name' do
|
99
|
-
it 'returns the store identifier' do
|
100
|
-
@store.directory_name.must_equal 'mem'
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
data/test/remote_files_test.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
describe RemoteFiles do
|
4
|
-
describe '::synchronize_stores' do
|
5
|
-
before do
|
6
|
-
@files = []
|
7
|
-
|
8
|
-
RemoteFiles.synchronize_stores do |file|
|
9
|
-
@files << file
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should use the block for store synchronizaation' do
|
14
|
-
file = RemoteFiles::File.new('file')
|
15
|
-
RemoteFiles.synchronize_stores(file)
|
16
|
-
@files.must_equal([file])
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
data/test/resque_job_test.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
require 'remote_files/resque_job'
|
3
|
-
|
4
|
-
describe RemoteFiles::ResqueJob do
|
5
|
-
describe 'loading the implementation file' do
|
6
|
-
before do
|
7
|
-
@file = RemoteFiles::File.new('identifier',
|
8
|
-
:content_type => 'text/plain',
|
9
|
-
:content => 'content',
|
10
|
-
:stored_in => [:s3],
|
11
|
-
:foo => :bar
|
12
|
-
)
|
13
|
-
|
14
|
-
load 'remote_files/resque_job.rb'
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should setup the right synchronize_stores hook' do
|
18
|
-
Resque.expects(:enqueue).with(RemoteFiles::ResqueJob,
|
19
|
-
:identifier => 'identifier',
|
20
|
-
:content_type => 'text/plain',
|
21
|
-
:stored_in => [:s3],
|
22
|
-
:foo => :bar,
|
23
|
-
:configuration => :default,
|
24
|
-
:_action => :synchronize
|
25
|
-
)
|
26
|
-
|
27
|
-
RemoteFiles.synchronize_stores(@file)
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should setup the right delete_file hook' do
|
31
|
-
Resque.expects(:enqueue).with(RemoteFiles::ResqueJob,
|
32
|
-
:identifier => 'identifier',
|
33
|
-
:content_type => 'text/plain',
|
34
|
-
:stored_in => [:s3],
|
35
|
-
:foo => :bar,
|
36
|
-
:configuration => :default,
|
37
|
-
:_action => :delete
|
38
|
-
)
|
39
|
-
|
40
|
-
RemoteFiles.delete_file(@file)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "running the job" do
|
45
|
-
before do
|
46
|
-
@options = {
|
47
|
-
:identifier => 'identifier',
|
48
|
-
:content_type => 'text/plain',
|
49
|
-
:stored_in => [:s3],
|
50
|
-
:foo => :bar
|
51
|
-
}
|
52
|
-
|
53
|
-
@file = stub
|
54
|
-
|
55
|
-
RemoteFiles::File.expects(:new).with('identifier',
|
56
|
-
:content_type => 'text/plain',
|
57
|
-
:stored_in => [:s3],
|
58
|
-
:foo => :bar
|
59
|
-
).returns(@file)
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'should call #synchronize! on the reconstructed file when asked to' do
|
63
|
-
@file.expects(:synchronize!)
|
64
|
-
|
65
|
-
RemoteFiles::ResqueJob.perform(@options.merge(:_action => :synchronize))
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'should call #delete_now! on the reconstructed file when asked to' do
|
69
|
-
@file.expects(:delete_now!)
|
70
|
-
|
71
|
-
RemoteFiles::ResqueJob.perform(@options.merge(:_action => :delete))
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'bundler/setup'
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'debugger'
|
5
|
-
rescue LoadError => e
|
6
|
-
end
|
7
|
-
|
8
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
9
|
-
require 'remote_files'
|
10
|
-
|
11
|
-
require 'minitest/autorun'
|
12
|
-
|
13
|
-
require 'mocha/setup'
|
14
|
-
|
15
|
-
Fog.mock!
|
16
|
-
|
17
|
-
MiniTest::Spec.class_eval do
|
18
|
-
before do
|
19
|
-
Fog::Mock.reset
|
20
|
-
|
21
|
-
RemoteFiles::CONFIGURATIONS.values.each do |conf|
|
22
|
-
conf.clear
|
23
|
-
end
|
24
|
-
|
25
|
-
RemoteFiles.synchronize_stores do |file|
|
26
|
-
end
|
27
|
-
|
28
|
-
RemoteFiles.delete_file do |file|
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|