durran-carrierwave 0.3.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Generators +4 -0
- data/History.txt +66 -0
- data/LICENSE +8 -0
- data/Manifest.txt +89 -0
- data/README.rdoc +342 -0
- data/Rakefile +30 -0
- data/carrierwave.gemspec +57 -0
- data/cucumber.yml +2 -0
- data/features/caching.feature +28 -0
- data/features/file_storage.feature +37 -0
- data/features/file_storage_overridden_filename.feature +38 -0
- data/features/file_storage_overridden_store_dir.feature +38 -0
- data/features/file_storage_reversing_processor.feature +43 -0
- data/features/fixtures/bork.txt +1 -0
- data/features/fixtures/monkey.txt +1 -0
- data/features/mount_activerecord.feature +46 -0
- data/features/mount_datamapper.feature +46 -0
- data/features/step_definitions/activerecord_steps.rb +22 -0
- data/features/step_definitions/caching_steps.rb +14 -0
- data/features/step_definitions/datamapper_steps.rb +29 -0
- data/features/step_definitions/file_steps.rb +42 -0
- data/features/step_definitions/general_steps.rb +80 -0
- data/features/step_definitions/mount_steps.rb +19 -0
- data/features/step_definitions/store_steps.rb +18 -0
- data/features/support/activerecord.rb +30 -0
- data/features/support/datamapper.rb +7 -0
- data/features/support/env.rb +35 -0
- data/features/versions_basics.feature +50 -0
- data/features/versions_nested_versions.feature +70 -0
- data/features/versions_overridden_filename.feature +51 -0
- data/features/versions_overriden_store_dir.feature +41 -0
- data/lib/carrierwave.rb +145 -0
- data/lib/carrierwave/compatibility/paperclip.rb +95 -0
- data/lib/carrierwave/core_ext/blank.rb +46 -0
- data/lib/carrierwave/core_ext/inheritable_attributes.rb +104 -0
- data/lib/carrierwave/core_ext/module_setup.rb +51 -0
- data/lib/carrierwave/mount.rb +332 -0
- data/lib/carrierwave/orm/activerecord.rb +73 -0
- data/lib/carrierwave/orm/datamapper.rb +27 -0
- data/lib/carrierwave/orm/mongomapper.rb +27 -0
- data/lib/carrierwave/orm/sequel.rb +57 -0
- data/lib/carrierwave/processing/image_science.rb +72 -0
- data/lib/carrierwave/processing/rmagick.rb +286 -0
- data/lib/carrierwave/sanitized_file.rb +272 -0
- data/lib/carrierwave/storage/abstract.rb +32 -0
- data/lib/carrierwave/storage/file.rb +50 -0
- data/lib/carrierwave/storage/s3.rb +215 -0
- data/lib/carrierwave/test/matchers.rb +114 -0
- data/lib/carrierwave/uploader.rb +43 -0
- data/lib/carrierwave/uploader/cache.rb +116 -0
- data/lib/carrierwave/uploader/callbacks.rb +42 -0
- data/lib/carrierwave/uploader/default_path.rb +23 -0
- data/lib/carrierwave/uploader/extension_whitelist.rb +37 -0
- data/lib/carrierwave/uploader/mountable.rb +39 -0
- data/lib/carrierwave/uploader/paths.rb +27 -0
- data/lib/carrierwave/uploader/processing.rb +81 -0
- data/lib/carrierwave/uploader/proxy.rb +62 -0
- data/lib/carrierwave/uploader/remove.rb +23 -0
- data/lib/carrierwave/uploader/store.rb +156 -0
- data/lib/carrierwave/uploader/url.rb +24 -0
- data/lib/carrierwave/uploader/versions.rb +147 -0
- data/lib/generators/uploader_generator.rb +22 -0
- data/rails_generators/uploader/USAGE +2 -0
- data/rails_generators/uploader/templates/uploader.rb +47 -0
- data/rails_generators/uploader/uploader_generator.rb +21 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/compatibility/paperclip_spec.rb +43 -0
- data/spec/fixtures/bork.txt +1 -0
- data/spec/fixtures/test.jpeg +1 -0
- data/spec/fixtures/test.jpg +1 -0
- data/spec/mount_spec.rb +517 -0
- data/spec/orm/activerecord_spec.rb +271 -0
- data/spec/orm/datamapper_spec.rb +161 -0
- data/spec/orm/mongomapper_spec.rb +184 -0
- data/spec/orm/sequel_spec.rb +192 -0
- data/spec/sanitized_file_spec.rb +612 -0
- data/spec/spec_helper.rb +99 -0
- data/spec/uploader/cache_spec.rb +196 -0
- data/spec/uploader/default_path_spec.rb +68 -0
- data/spec/uploader/extension_whitelist_spec.rb +44 -0
- data/spec/uploader/mountable_spec.rb +33 -0
- data/spec/uploader/paths_spec.rb +22 -0
- data/spec/uploader/processing_spec.rb +62 -0
- data/spec/uploader/proxy_spec.rb +54 -0
- data/spec/uploader/remove_spec.rb +70 -0
- data/spec/uploader/store_spec.rb +274 -0
- data/spec/uploader/url_spec.rb +87 -0
- data/spec/uploader/versions_spec.rb +306 -0
- metadata +228 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
4
|
+
|
5
|
+
describe CarrierWave::Uploader do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@uploader_class = Class.new(CarrierWave::Uploader::Base)
|
9
|
+
@uploader = @uploader_class.new
|
10
|
+
end
|
11
|
+
|
12
|
+
after do
|
13
|
+
FileUtils.rm_rf(public_path)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '.process' do
|
17
|
+
it "should add a single processor when a symbol is given" do
|
18
|
+
@uploader_class.process :sepiatone
|
19
|
+
@uploader.should_receive(:sepiatone)
|
20
|
+
@uploader.process!
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should add multiple processors when an array of symbols is given" do
|
24
|
+
@uploader_class.process :sepiatone, :desaturate, :invert
|
25
|
+
@uploader.should_receive(:sepiatone)
|
26
|
+
@uploader.should_receive(:desaturate)
|
27
|
+
@uploader.should_receive(:invert)
|
28
|
+
@uploader.process!
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should add a single processor with an argument when a hash is given" do
|
32
|
+
@uploader_class.process :format => 'png'
|
33
|
+
@uploader.should_receive(:format).with('png')
|
34
|
+
@uploader.process!
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should add a single processor with several argument when a hash is given" do
|
38
|
+
@uploader_class.process :resize => [200, 300]
|
39
|
+
@uploader.should_receive(:resize).with(200, 300)
|
40
|
+
@uploader.process!
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should add multiple processors when an hash with multiple keys is given" do
|
44
|
+
@uploader_class.process :resize => [200, 300], :format => 'png'
|
45
|
+
@uploader.should_receive(:resize).with(200, 300)
|
46
|
+
@uploader.should_receive(:format).with('png')
|
47
|
+
@uploader.process!
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#cache!' do
|
52
|
+
before do
|
53
|
+
CarrierWave.stub!(:generate_cache_id).and_return('20071201-1234-345-2255')
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should trigger a process!" do
|
57
|
+
@uploader.should_receive(:process!)
|
58
|
+
@uploader.cache!(File.open(file_path('test.jpg')))
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
4
|
+
|
5
|
+
describe CarrierWave::Uploader do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@uploader_class = Class.new(CarrierWave::Uploader::Base)
|
9
|
+
@uploader = @uploader_class.new
|
10
|
+
end
|
11
|
+
|
12
|
+
after do
|
13
|
+
FileUtils.rm_rf(public_path)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#blank?' do
|
17
|
+
it "should be true when nothing has been done" do
|
18
|
+
@uploader.should be_blank
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should not be true when the file is empty" do
|
22
|
+
@uploader.retrieve_from_cache!('20071201-1234-345-2255/test.jpeg')
|
23
|
+
@uploader.should be_blank
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should not be true when a file has been cached" do
|
27
|
+
@uploader.cache!(File.open(file_path('test.jpg')))
|
28
|
+
@uploader.should_not be_blank
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#read' do
|
33
|
+
it "should be nil by default" do
|
34
|
+
@uploader.read.should be_nil
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should read the contents of a cached file" do
|
38
|
+
@uploader.cache!(File.open(file_path('test.jpg')))
|
39
|
+
@uploader.read.should == "this is stuff"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#size' do
|
44
|
+
it "should be zero by default" do
|
45
|
+
@uploader.size.should == 0
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should get the size of a cached file" do
|
49
|
+
@uploader.cache!(File.open(file_path('test.jpg')))
|
50
|
+
@uploader.size.should == 13
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
4
|
+
|
5
|
+
describe CarrierWave::Uploader do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@uploader_class = Class.new(CarrierWave::Uploader::Base)
|
9
|
+
@uploader = @uploader_class.new
|
10
|
+
end
|
11
|
+
|
12
|
+
after do
|
13
|
+
FileUtils.rm_rf(public_path)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#remove!' do
|
17
|
+
before do
|
18
|
+
@file = File.open(file_path('test.jpg'))
|
19
|
+
|
20
|
+
@stored_file = mock('a stored file')
|
21
|
+
@stored_file.stub!(:path).and_return('/path/to/somewhere')
|
22
|
+
@stored_file.stub!(:url).and_return('http://www.example.com')
|
23
|
+
@stored_file.stub!(:identifier).and_return('this-is-me')
|
24
|
+
@stored_file.stub!(:delete)
|
25
|
+
|
26
|
+
@storage = mock('a storage engine')
|
27
|
+
@storage.stub!(:store!).and_return(@stored_file)
|
28
|
+
|
29
|
+
@uploader_class.storage.stub!(:new).and_return(@storage)
|
30
|
+
@uploader.store!(@file)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should reset the current path" do
|
34
|
+
@uploader.remove!
|
35
|
+
@uploader.current_path.should be_nil
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should not be cached" do
|
39
|
+
@uploader.remove!
|
40
|
+
@uploader.should_not be_cached
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should reset the url" do
|
44
|
+
@uploader.cache!(@file)
|
45
|
+
@uploader.remove!
|
46
|
+
@uploader.url.should be_nil
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should reset the identifier" do
|
50
|
+
@uploader.remove!
|
51
|
+
@uploader.identifier.should be_nil
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should delete the file" do
|
55
|
+
@stored_file.should_receive(:delete)
|
56
|
+
@uploader.remove!
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should reset the cache_name" do
|
60
|
+
@uploader.cache!(@file)
|
61
|
+
@uploader.remove!
|
62
|
+
@uploader.cache_name.should be_nil
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should do nothing when trying to remove an empty file" do
|
66
|
+
running { @uploader.remove! }.should_not raise_error
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,274 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
4
|
+
|
5
|
+
describe CarrierWave::Uploader do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@uploader_class = Class.new(CarrierWave::Uploader::Base)
|
9
|
+
@uploader = @uploader_class.new
|
10
|
+
end
|
11
|
+
|
12
|
+
after do
|
13
|
+
FileUtils.rm_rf(public_path)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe ".storage" do
|
17
|
+
before do
|
18
|
+
CarrierWave::Storage::File.stub!(:setup!)
|
19
|
+
CarrierWave::Storage::S3.stub!(:setup!)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should set the storage if an argument is given" do
|
23
|
+
storage = mock('some kind of storage')
|
24
|
+
storage.should_receive(:setup!)
|
25
|
+
@uploader_class.storage storage
|
26
|
+
@uploader_class.storage.should == storage
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should default to file" do
|
30
|
+
@uploader_class.storage.should == CarrierWave::Storage::File
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should set the storage from the configured shortcuts if a symbol is given" do
|
34
|
+
@uploader_class.storage :file
|
35
|
+
@uploader_class.storage.should == CarrierWave::Storage::File
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should remember the storage when inherited" do
|
39
|
+
@uploader_class.storage :s3
|
40
|
+
subclass = Class.new(@uploader_class)
|
41
|
+
subclass.storage.should == CarrierWave::Storage::S3
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should be changeable when inherited" do
|
45
|
+
@uploader_class.storage :s3
|
46
|
+
subclass = Class.new(@uploader_class)
|
47
|
+
subclass.storage.should == CarrierWave::Storage::S3
|
48
|
+
subclass.storage :file
|
49
|
+
subclass.storage.should == CarrierWave::Storage::File
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#store_dir' do
|
54
|
+
it "should default to the config option" do
|
55
|
+
@uploader.store_dir.should == 'uploads'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#filename' do
|
60
|
+
it "should default to nil" do
|
61
|
+
@uploader.filename.should be_nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#store!' do
|
66
|
+
before do
|
67
|
+
@file = File.open(file_path('test.jpg'))
|
68
|
+
|
69
|
+
@stored_file = mock('a stored file')
|
70
|
+
@stored_file.stub!(:path).and_return('/path/to/somewhere')
|
71
|
+
@stored_file.stub!(:url).and_return('http://www.example.com')
|
72
|
+
|
73
|
+
@storage = mock('a storage engine')
|
74
|
+
@storage.stub!(:store!).and_return(@stored_file)
|
75
|
+
@storage.stub!(:identifier).and_return('this-is-me')
|
76
|
+
|
77
|
+
@uploader_class.storage.stub!(:new).with(@uploader).and_return(@storage)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should set the current path" do
|
81
|
+
@uploader.store!(@file)
|
82
|
+
@uploader.current_path.should == '/path/to/somewhere'
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should not be cached" do
|
86
|
+
@uploader.store!(@file)
|
87
|
+
@uploader.should_not be_cached
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should set the url" do
|
91
|
+
@uploader.store!(@file)
|
92
|
+
@uploader.url.should == 'http://www.example.com'
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should set the identifier" do
|
96
|
+
@uploader.store!(@file)
|
97
|
+
@uploader.identifier.should == 'this-is-me'
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should, if a file is given as argument, cache that file" do
|
101
|
+
@uploader.should_receive(:cache!).with(@file)
|
102
|
+
@uploader.store!(@file)
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should use a previously cached file if no argument is given" do
|
106
|
+
@uploader.cache!(File.open(file_path('test.jpg')))
|
107
|
+
@uploader.should_not_receive(:cache!)
|
108
|
+
@uploader.store!
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should instruct the storage engine to store the file" do
|
112
|
+
@uploader.cache!(@file)
|
113
|
+
@storage.should_receive(:store!).with(@uploader.file).and_return(:monkey)
|
114
|
+
@uploader.store!
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should reset the cache_name" do
|
118
|
+
@uploader.cache!(@file)
|
119
|
+
@uploader.store!
|
120
|
+
@uploader.cache_name.should be_nil
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should cache the result given by the storage engine" do
|
124
|
+
@uploader.store!(@file)
|
125
|
+
@uploader.file.should == @stored_file
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should do nothing when trying to store an empty file" do
|
129
|
+
@uploader.store!(nil)
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should not re-store a retrieved file" do
|
133
|
+
@stored_file = mock('a stored file')
|
134
|
+
@storage.stub!(:retrieve!).and_return(@stored_file)
|
135
|
+
|
136
|
+
@uploader_class.storage.should_not_receive(:store!)
|
137
|
+
@uploader.retrieve_from_store!('monkey.txt')
|
138
|
+
@uploader.store!
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe '#retrieve_from_store!' do
|
143
|
+
before do
|
144
|
+
@stored_file = mock('a stored file')
|
145
|
+
@stored_file.stub!(:path).and_return('/path/to/somewhere')
|
146
|
+
@stored_file.stub!(:url).and_return('http://www.example.com')
|
147
|
+
|
148
|
+
@storage = mock('a storage engine')
|
149
|
+
@storage.stub!(:retrieve!).and_return(@stored_file)
|
150
|
+
@storage.stub!(:identifier).and_return('this-is-me')
|
151
|
+
|
152
|
+
@uploader_class.storage.stub!(:new).with(@uploader).and_return(@storage)
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should set the current path" do
|
156
|
+
@uploader.retrieve_from_store!('monkey.txt')
|
157
|
+
@uploader.current_path.should == '/path/to/somewhere'
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should not be cached" do
|
161
|
+
@uploader.retrieve_from_store!('monkey.txt')
|
162
|
+
@uploader.should_not be_cached
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should set the url" do
|
166
|
+
@uploader.retrieve_from_store!('monkey.txt')
|
167
|
+
@uploader.url.should == 'http://www.example.com'
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should set the identifier" do
|
171
|
+
@uploader.retrieve_from_store!('monkey.txt')
|
172
|
+
@uploader.identifier.should == 'this-is-me'
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should instruct the storage engine to retrieve the file and store the result" do
|
176
|
+
@storage.should_receive(:retrieve!).with('monkey.txt').and_return(@stored_file)
|
177
|
+
@uploader.retrieve_from_store!('monkey.txt')
|
178
|
+
@uploader.file.should == @stored_file
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should overwrite a file that has already been cached" do
|
182
|
+
@uploader.retrieve_from_cache!('20071201-1234-345-2255/test.jpeg')
|
183
|
+
@uploader.retrieve_from_store!('bork.txt')
|
184
|
+
@uploader.file.should == @stored_file
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
describe 'with an overridden, reversing, filename' do
|
189
|
+
before do
|
190
|
+
@uploader_class.class_eval do
|
191
|
+
def filename
|
192
|
+
super.reverse unless super.blank?
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
describe '#store!' do
|
198
|
+
before do
|
199
|
+
@file = File.open(file_path('test.jpg'))
|
200
|
+
|
201
|
+
@stored_file = mock('a stored file')
|
202
|
+
@stored_file.stub!(:path).and_return('/path/to/somewhere')
|
203
|
+
@stored_file.stub!(:url).and_return('http://www.example.com')
|
204
|
+
|
205
|
+
@storage = mock('a storage engine')
|
206
|
+
@storage.stub!(:store!).and_return(@stored_file)
|
207
|
+
|
208
|
+
@uploader_class.storage.stub!(:new).with(@uploader).and_return(@storage)
|
209
|
+
end
|
210
|
+
|
211
|
+
after do
|
212
|
+
CarrierWave.config[:use_cache] = true
|
213
|
+
end
|
214
|
+
|
215
|
+
it "should set the current path" do
|
216
|
+
@uploader.store!(@file)
|
217
|
+
@uploader.current_path.should == '/path/to/somewhere'
|
218
|
+
end
|
219
|
+
|
220
|
+
it "should set the url" do
|
221
|
+
@uploader.store!(@file)
|
222
|
+
@uploader.url.should == 'http://www.example.com'
|
223
|
+
end
|
224
|
+
|
225
|
+
it "should, if a file is given as argument, reverse the filename" do
|
226
|
+
@uploader.store!(@file)
|
227
|
+
@uploader.filename.should == 'gpj.tset'
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should, if a files is given as an argument and use_cache is false, reverse the filename" do
|
231
|
+
CarrierWave.config[:use_cache] = false
|
232
|
+
@uploader.store!(@file)
|
233
|
+
@uploader.filename.should == 'gpj.tset'
|
234
|
+
end
|
235
|
+
|
236
|
+
end
|
237
|
+
|
238
|
+
describe '#retrieve_from_store!' do
|
239
|
+
before do
|
240
|
+
@stored_file = mock('a stored file')
|
241
|
+
@stored_file.stub!(:path).and_return('/path/to/somewhere')
|
242
|
+
@stored_file.stub!(:url).and_return('http://www.example.com')
|
243
|
+
|
244
|
+
@storage = mock('a storage engine')
|
245
|
+
@storage.stub!(:retrieve!).and_return(@stored_file)
|
246
|
+
|
247
|
+
@uploader_class.storage.stub!(:new).with(@uploader).and_return(@storage)
|
248
|
+
end
|
249
|
+
|
250
|
+
it "should set the current path" do
|
251
|
+
@uploader.retrieve_from_store!('monkey.txt')
|
252
|
+
@uploader.current_path.should == '/path/to/somewhere'
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should set the url" do
|
256
|
+
@uploader.retrieve_from_store!('monkey.txt')
|
257
|
+
@uploader.url.should == 'http://www.example.com'
|
258
|
+
end
|
259
|
+
|
260
|
+
it "should pass the identifier to the storage engine" do
|
261
|
+
@storage.should_receive(:retrieve!).with('monkey.txt').and_return(@stored_file)
|
262
|
+
@uploader.retrieve_from_store!('monkey.txt')
|
263
|
+
@uploader.file.should == @stored_file
|
264
|
+
end
|
265
|
+
|
266
|
+
it "should not set the filename" do
|
267
|
+
@uploader.retrieve_from_store!('monkey.txt')
|
268
|
+
@uploader.filename.should be_nil
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
end
|
273
|
+
|
274
|
+
end
|