carrierwave 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of carrierwave might be problematic. Click here for more details.
- data/README.rdoc +33 -15
- data/lib/carrierwave.rb +0 -1
- data/lib/carrierwave/compatibility/paperclip.rb +2 -2
- data/lib/carrierwave/orm/activerecord.rb +9 -5
- data/lib/carrierwave/orm/datamapper.rb +10 -0
- data/lib/carrierwave/processing/mini_magick.rb +1 -1
- data/lib/carrierwave/processing/rmagick.rb +4 -4
- data/lib/carrierwave/sanitized_file.rb +2 -2
- data/lib/carrierwave/storage/cloud_files.rb +11 -12
- data/lib/carrierwave/storage/grid_fs.rb +37 -26
- data/lib/carrierwave/storage/right_s3.rb +1 -168
- data/lib/carrierwave/storage/s3.rb +73 -66
- data/lib/carrierwave/test/matchers.rb +57 -21
- data/lib/carrierwave/uploader/configuration.rb +8 -5
- data/lib/carrierwave/uploader/processing.rb +1 -0
- data/lib/carrierwave/uploader/url.rb +2 -2
- data/lib/carrierwave/uploader/versions.rb +10 -0
- metadata +31 -279
- data/Generators +0 -4
- data/History.txt +0 -125
- data/Manifest.txt +0 -111
- data/Rakefile +0 -39
- data/carrierwave.gemspec +0 -85
- data/cucumber.yml +0 -2
- data/features/caching.feature +0 -28
- data/features/download.feature +0 -20
- data/features/file_storage.feature +0 -37
- data/features/file_storage_overridden_filename.feature +0 -38
- data/features/file_storage_overridden_store_dir.feature +0 -38
- data/features/file_storage_reversing_processor.feature +0 -43
- data/features/fixtures/bork.txt +0 -1
- data/features/fixtures/monkey.txt +0 -1
- data/features/grid_fs_storage.feature +0 -32
- data/features/mount_activerecord.feature +0 -46
- data/features/mount_datamapper.feature +0 -46
- data/features/step_definitions/activerecord_steps.rb +0 -22
- data/features/step_definitions/caching_steps.rb +0 -14
- data/features/step_definitions/datamapper_steps.rb +0 -29
- data/features/step_definitions/download_steps.rb +0 -4
- data/features/step_definitions/file_steps.rb +0 -53
- data/features/step_definitions/general_steps.rb +0 -85
- data/features/step_definitions/mount_steps.rb +0 -19
- data/features/step_definitions/store_steps.rb +0 -18
- data/features/support/activerecord.rb +0 -30
- data/features/support/datamapper.rb +0 -7
- data/features/support/env.rb +0 -22
- data/features/versions_basics.feature +0 -50
- data/features/versions_nested_versions.feature +0 -70
- data/features/versions_overridden_filename.feature +0 -51
- data/features/versions_overriden_store_dir.feature +0 -41
- data/lib/carrierwave/orm/mongomapper.rb +0 -27
- data/merb_generators/uploader_generator.rb +0 -22
- data/rails_generators/uploader/USAGE +0 -2
- data/rails_generators/uploader/templates/uploader.rb +0 -47
- data/rails_generators/uploader/uploader_generator.rb +0 -21
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/spec/compatibility/paperclip_spec.rb +0 -52
- data/spec/fixtures/bork.txt +0 -1
- data/spec/fixtures/landscape.jpg +0 -0
- data/spec/fixtures/portrait.jpg +0 -0
- data/spec/fixtures/test.jpeg +0 -1
- data/spec/fixtures/test.jpg +0 -1
- data/spec/mount_spec.rb +0 -538
- data/spec/orm/activerecord_spec.rb +0 -271
- data/spec/orm/datamapper_spec.rb +0 -168
- data/spec/orm/mongoid_spec.rb +0 -202
- data/spec/orm/mongomapper_spec.rb +0 -202
- data/spec/orm/sequel_spec.rb +0 -183
- data/spec/processing/image_science_spec.rb +0 -56
- data/spec/processing/mini_magick_spec.rb +0 -76
- data/spec/processing/rmagick_spec.rb +0 -75
- data/spec/sanitized_file_spec.rb +0 -623
- data/spec/spec_helper.rb +0 -92
- data/spec/storage/cloudfiles_spec.rb +0 -78
- data/spec/storage/grid_fs_spec.rb +0 -83
- data/spec/storage/right_s3_spec.rb +0 -83
- data/spec/storage/s3_spec.rb +0 -95
- data/spec/uploader/cache_spec.rb +0 -209
- data/spec/uploader/configuration_spec.rb +0 -105
- data/spec/uploader/default_url_spec.rb +0 -85
- data/spec/uploader/download_spec.rb +0 -75
- data/spec/uploader/extension_whitelist_spec.rb +0 -44
- data/spec/uploader/mountable_spec.rb +0 -33
- data/spec/uploader/paths_spec.rb +0 -22
- data/spec/uploader/processing_spec.rb +0 -73
- data/spec/uploader/proxy_spec.rb +0 -54
- data/spec/uploader/remove_spec.rb +0 -70
- data/spec/uploader/store_spec.rb +0 -264
- data/spec/uploader/url_spec.rb +0 -102
- data/spec/uploader/versions_spec.rb +0 -298
@@ -1,75 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
4
|
-
|
5
|
-
describe CarrierWave::RMagick do
|
6
|
-
|
7
|
-
before do
|
8
|
-
@klass = Class.new do
|
9
|
-
include CarrierWave::RMagick
|
10
|
-
end
|
11
|
-
@instance = @klass.new
|
12
|
-
FileUtils.cp(file_path('landscape.jpg'), file_path('landscape_copy.jpg'))
|
13
|
-
@instance.stub(:current_path).and_return(file_path('landscape_copy.jpg'))
|
14
|
-
end
|
15
|
-
|
16
|
-
after do
|
17
|
-
FileUtils.rm(file_path('landscape_copy.jpg'))
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#convert' do
|
21
|
-
it "should convert the image to the given format" do
|
22
|
-
# TODO: find some way to spec this
|
23
|
-
@instance.convert(:png)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '#resize_to_fill' do
|
28
|
-
it "should resize the image to exactly the given dimensions" do
|
29
|
-
@instance.resize_to_fill(200, 200)
|
30
|
-
@instance.should have_dimensions(200, 200)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should scale up the image if it smaller than the given dimensions" do
|
34
|
-
@instance.resize_to_fill(1000, 1000)
|
35
|
-
@instance.should have_dimensions(1000, 1000)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe '#resize_and_pad' do
|
40
|
-
it "should resize the image to exactly the given dimensions" do
|
41
|
-
@instance.resize_and_pad(200, 200)
|
42
|
-
@instance.should have_dimensions(200, 200)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should scale up the image if it smaller than the given dimensions" do
|
46
|
-
@instance.resize_and_pad(1000, 1000)
|
47
|
-
@instance.should have_dimensions(1000, 1000)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe '#resize_to_fit' do
|
52
|
-
it "should resize the image to fit within the given dimensions" do
|
53
|
-
@instance.resize_to_fit(200, 200)
|
54
|
-
@instance.should have_dimensions(200, 150)
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should scale up the image if it smaller than the given dimensions" do
|
58
|
-
@instance.resize_to_fit(1000, 1000)
|
59
|
-
@instance.should have_dimensions(1000, 750)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe '#resize_to_limit' do
|
64
|
-
it "should resize the image to fit within the given dimensions" do
|
65
|
-
@instance.resize_to_limit(200, 200)
|
66
|
-
@instance.should have_dimensions(200, 150)
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should not scale up the image if it smaller than the given dimensions" do
|
70
|
-
@instance.resize_to_limit(1000, 1000)
|
71
|
-
@instance.should have_dimensions(640, 480)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
data/spec/sanitized_file_spec.rb
DELETED
@@ -1,623 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
4
|
-
|
5
|
-
describe CarrierWave::SanitizedFile do
|
6
|
-
|
7
|
-
before do
|
8
|
-
unless File.exists?(file_path('llama.jpg'))
|
9
|
-
FileUtils.cp(file_path('test.jpg'), file_path('llama.jpg'))
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
after(:all) do
|
14
|
-
if File.exists?(file_path('llama.jpg'))
|
15
|
-
FileUtils.rm(file_path('llama.jpg'))
|
16
|
-
end
|
17
|
-
FileUtils.rm_rf(public_path)
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#empty?' do
|
21
|
-
|
22
|
-
it "should be empty for nil" do
|
23
|
-
@sanitized_file = CarrierWave::SanitizedFile.new(nil)
|
24
|
-
@sanitized_file.should be_empty
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should be empty for an empty string" do
|
28
|
-
@sanitized_file = CarrierWave::SanitizedFile.new("")
|
29
|
-
@sanitized_file.should be_empty
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should be empty for an empty StringIO" do
|
33
|
-
@sanitized_file = CarrierWave::SanitizedFile.new(StringIO.new(""))
|
34
|
-
@sanitized_file.should be_empty
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should be empty for a file with a zero size" do
|
38
|
-
FileUtils.rm file_path('llama.jpg')
|
39
|
-
FileUtils.touch file_path('llama.jpg')
|
40
|
-
|
41
|
-
@sanitized_file = CarrierWave::SanitizedFile.new(File.open(file_path('llama.jpg')))
|
42
|
-
@sanitized_file.should be_empty
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
describe '#original_filename' do
|
48
|
-
it "should default to the original_filename" do
|
49
|
-
file = mock('file', :original_filename => 'llama.jpg')
|
50
|
-
sanitized_file = CarrierWave::SanitizedFile.new(file)
|
51
|
-
sanitized_file.original_filename.should == "llama.jpg"
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should defer to the base name of the path if original_filename is unavailable" do
|
55
|
-
file = mock('file', :path => '/path/to/test.jpg')
|
56
|
-
sanitized_file = CarrierWave::SanitizedFile.new(file)
|
57
|
-
sanitized_file.original_filename.should == "test.jpg"
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should be nil otherwise" do
|
61
|
-
file = mock('file')
|
62
|
-
sanitized_file = CarrierWave::SanitizedFile.new(file)
|
63
|
-
sanitized_file.original_filename.should be_nil
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe '#basename' do
|
68
|
-
it "should return the basename for complicated extensions" do
|
69
|
-
@sanitized_file = CarrierWave::SanitizedFile.new(file_path('complex.filename.tar.gz'))
|
70
|
-
@sanitized_file.basename.should == "complex.filename"
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should be the filename if the file has no extension" do
|
74
|
-
@sanitized_file = CarrierWave::SanitizedFile.new(file_path('complex'))
|
75
|
-
@sanitized_file.basename.should == "complex"
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe '#extension' do
|
80
|
-
it "should return the extension for complicated extensions" do
|
81
|
-
@sanitized_file = CarrierWave::SanitizedFile.new(file_path('complex.filename.tar.gz'))
|
82
|
-
@sanitized_file.extension.should == "tar.gz"
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should return the extension for real-world user file names" do
|
86
|
-
@sanitized_file = CarrierWave::SanitizedFile.new(file_path('Photo on 2009-12-01 at 11.12.jpg'))
|
87
|
-
@sanitized_file.extension.should == "jpg"
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should return the extension for basic filenames" do
|
91
|
-
@sanitized_file = CarrierWave::SanitizedFile.new(file_path('something.png'))
|
92
|
-
@sanitized_file.extension.should == "png"
|
93
|
-
end
|
94
|
-
|
95
|
-
it "should be an empty string if the file has no extension" do
|
96
|
-
@sanitized_file = CarrierWave::SanitizedFile.new(file_path('complex'))
|
97
|
-
@sanitized_file.extension.should == ""
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
describe '#filename' do
|
102
|
-
|
103
|
-
before do
|
104
|
-
@sanitized_file = CarrierWave::SanitizedFile.new(nil)
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should default to the original filename if it is valid" do
|
108
|
-
@sanitized_file.should_receive(:original_filename).at_least(:once).and_return("llama.jpg")
|
109
|
-
@sanitized_file.filename.should == "llama.jpg"
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should remove illegal characters from a filename" do
|
113
|
-
@sanitized_file.should_receive(:original_filename).at_least(:once).and_return("test-s,%&m#st?.jpg")
|
114
|
-
@sanitized_file.filename.should == "test-s___m_st_.jpg"
|
115
|
-
end
|
116
|
-
|
117
|
-
it "should remove slashes from the filename" do
|
118
|
-
@sanitized_file.should_receive(:original_filename).at_least(:once).and_return("../../very_tricky/foo.bar")
|
119
|
-
@sanitized_file.filename.should_not =~ /[\\\/]/
|
120
|
-
end
|
121
|
-
|
122
|
-
it "should remove illegal characters if there is no extension" do
|
123
|
-
@sanitized_file.should_receive(:original_filename).at_least(:once).and_return('`*foo')
|
124
|
-
@sanitized_file.filename.should == "__foo"
|
125
|
-
end
|
126
|
-
|
127
|
-
it "should remove the path prefix on Windows" do
|
128
|
-
@sanitized_file.should_receive(:original_filename).at_least(:once).and_return('c:\temp\foo.txt')
|
129
|
-
@sanitized_file.filename.should == "foo.txt"
|
130
|
-
end
|
131
|
-
|
132
|
-
it "should make sure the *nix directory thingies can't be used as filenames" do
|
133
|
-
@sanitized_file.should_receive(:original_filename).at_least(:once).and_return(".")
|
134
|
-
@sanitized_file.filename.should == "_."
|
135
|
-
end
|
136
|
-
|
137
|
-
it "should downcase uppercase filenames" do
|
138
|
-
@sanitized_file.should_receive(:original_filename).at_least(:once).and_return("DSC4056.JPG")
|
139
|
-
@sanitized_file.filename.should == "dsc4056.jpg"
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|
143
|
-
|
144
|
-
shared_examples_for "all valid sanitized files" do
|
145
|
-
|
146
|
-
describe '#empty?' do
|
147
|
-
it "should not be empty" do
|
148
|
-
@sanitized_file.should_not be_empty
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
describe '#original_filename' do
|
153
|
-
it "should return the original filename" do
|
154
|
-
@sanitized_file.original_filename.should == "llama.jpg"
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
describe '#filename' do
|
159
|
-
it "should return the filename" do
|
160
|
-
@sanitized_file.filename.should == "llama.jpg"
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
describe '#basename' do
|
165
|
-
it "should return the basename" do
|
166
|
-
@sanitized_file.basename.should == "llama"
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
describe '#extension' do
|
171
|
-
it "should return the extension" do
|
172
|
-
@sanitized_file.extension.should == "jpg"
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
describe "#read" do
|
177
|
-
it "should return the contents of the file" do
|
178
|
-
@sanitized_file.read.should == "this is stuff"
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
describe "#size" do
|
183
|
-
it "should return the size of the file" do
|
184
|
-
@sanitized_file.size.should == 13
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
describe '#move_to' do
|
189
|
-
|
190
|
-
after do
|
191
|
-
FileUtils.rm(file_path('gurr.png'))
|
192
|
-
end
|
193
|
-
|
194
|
-
it "should be moved to the correct location" do
|
195
|
-
@sanitized_file.move_to(file_path('gurr.png'))
|
196
|
-
|
197
|
-
File.exists?( file_path('gurr.png') ).should be_true
|
198
|
-
end
|
199
|
-
|
200
|
-
it "should have changed its path when moved" do
|
201
|
-
@sanitized_file.move_to(file_path('gurr.png'))
|
202
|
-
@sanitized_file.path.should == file_path('gurr.png')
|
203
|
-
end
|
204
|
-
|
205
|
-
it "should have changed its filename when moved" do
|
206
|
-
@sanitized_file.move_to(file_path('gurr.png'))
|
207
|
-
@sanitized_file.filename.should == 'gurr.png'
|
208
|
-
end
|
209
|
-
|
210
|
-
it "should have changed its basename when moved" do
|
211
|
-
@sanitized_file.move_to(file_path('gurr.png'))
|
212
|
-
@sanitized_file.basename.should == 'gurr'
|
213
|
-
end
|
214
|
-
|
215
|
-
it "should have changed its extension when moved" do
|
216
|
-
@sanitized_file.move_to(file_path('gurr.png'))
|
217
|
-
@sanitized_file.extension.should == 'png'
|
218
|
-
end
|
219
|
-
|
220
|
-
it "should set the right permissions" do
|
221
|
-
@sanitized_file.move_to(file_path('gurr.png'), 0755)
|
222
|
-
@sanitized_file.should have_permissions(0755)
|
223
|
-
end
|
224
|
-
|
225
|
-
end
|
226
|
-
|
227
|
-
describe '#copy_to' do
|
228
|
-
|
229
|
-
after do
|
230
|
-
FileUtils.rm(file_path('gurr.png'))
|
231
|
-
end
|
232
|
-
|
233
|
-
it "should be copied to the correct location" do
|
234
|
-
@sanitized_file.copy_to(file_path('gurr.png'))
|
235
|
-
|
236
|
-
File.exists?( file_path('gurr.png') ).should be_true
|
237
|
-
|
238
|
-
file_path('gurr.png').should be_identical_to(file_path('llama.jpg'))
|
239
|
-
end
|
240
|
-
|
241
|
-
it "should not have changed its path when copied" do
|
242
|
-
running { @sanitized_file.copy_to(file_path('gurr.png')) }.should_not change(@sanitized_file, :path)
|
243
|
-
end
|
244
|
-
|
245
|
-
it "should not have changed its filename when copied" do
|
246
|
-
running { @sanitized_file.copy_to(file_path('gurr.png')) }.should_not change(@sanitized_file, :filename)
|
247
|
-
end
|
248
|
-
|
249
|
-
it "should return an object of the same class when copied" do
|
250
|
-
new_file = @sanitized_file.copy_to(file_path('gurr.png'))
|
251
|
-
new_file.should be_an_instance_of(@sanitized_file.class)
|
252
|
-
end
|
253
|
-
|
254
|
-
it "should adjust the path of the object that is returned when copied" do
|
255
|
-
new_file = @sanitized_file.copy_to(file_path('gurr.png'))
|
256
|
-
new_file.path.should == file_path('gurr.png')
|
257
|
-
end
|
258
|
-
|
259
|
-
it "should adjust the filename of the object that is returned when copied" do
|
260
|
-
new_file = @sanitized_file.copy_to(file_path('gurr.png'))
|
261
|
-
new_file.filename.should == 'gurr.png'
|
262
|
-
end
|
263
|
-
|
264
|
-
it "should adjust the basename of the object that is returned when copied" do
|
265
|
-
new_file = @sanitized_file.copy_to(file_path('gurr.png'))
|
266
|
-
new_file.basename.should == 'gurr'
|
267
|
-
end
|
268
|
-
|
269
|
-
it "should adjust the extension of the object that is returned when copied" do
|
270
|
-
new_file = @sanitized_file.copy_to(file_path('gurr.png'))
|
271
|
-
new_file.extension.should == 'png'
|
272
|
-
end
|
273
|
-
|
274
|
-
it "should set the right permissions" do
|
275
|
-
new_file = @sanitized_file.copy_to(file_path('gurr.png'), 0755)
|
276
|
-
new_file.should have_permissions(0755)
|
277
|
-
end
|
278
|
-
|
279
|
-
end
|
280
|
-
|
281
|
-
end
|
282
|
-
|
283
|
-
shared_examples_for "all valid sanitized files that are stored on disk" do
|
284
|
-
describe '#move_to' do
|
285
|
-
it "should not raise an error when moved to its own location" do
|
286
|
-
running { @sanitized_file.move_to(@sanitized_file.path) }.should_not raise_error
|
287
|
-
end
|
288
|
-
|
289
|
-
it "should remove the original file" do
|
290
|
-
original_path = @sanitized_file.path
|
291
|
-
@sanitized_file.move_to(public_path('blah.txt'))
|
292
|
-
File.exist?(original_path).should be_false
|
293
|
-
end
|
294
|
-
end
|
295
|
-
|
296
|
-
describe '#copy_to' do
|
297
|
-
it "should return a new instance when copied to its own location" do
|
298
|
-
running {
|
299
|
-
new_file = @sanitized_file.copy_to(@sanitized_file.path)
|
300
|
-
new_file.should be_an_instance_of(@sanitized_file.class)
|
301
|
-
}.should_not raise_error
|
302
|
-
end
|
303
|
-
|
304
|
-
it "should not remove the original file" do
|
305
|
-
new_file = @sanitized_file.copy_to(public_path('blah.txt'))
|
306
|
-
File.exist?(@sanitized_file.path).should be_true
|
307
|
-
File.exist?(new_file.path).should be_true
|
308
|
-
end
|
309
|
-
end
|
310
|
-
|
311
|
-
describe '#exists?' do
|
312
|
-
it "should be true" do
|
313
|
-
@sanitized_file.exists?.should be_true
|
314
|
-
end
|
315
|
-
end
|
316
|
-
|
317
|
-
describe '#delete' do
|
318
|
-
it "should remove it from the filesystem" do
|
319
|
-
File.exists?(@sanitized_file.path).should be_true
|
320
|
-
@sanitized_file.delete
|
321
|
-
File.exists?(@sanitized_file.path).should be_false
|
322
|
-
end
|
323
|
-
end
|
324
|
-
end
|
325
|
-
|
326
|
-
describe "with a valid Hash" do
|
327
|
-
before do
|
328
|
-
@hash = {
|
329
|
-
"tempfile" => stub_merb_tempfile('llama.jpg'),
|
330
|
-
"filename" => "llama.jpg",
|
331
|
-
"content_type" => 'image/jpeg'
|
332
|
-
}
|
333
|
-
@sanitized_file = CarrierWave::SanitizedFile.new(@hash)
|
334
|
-
end
|
335
|
-
|
336
|
-
it_should_behave_like "all valid sanitized files"
|
337
|
-
|
338
|
-
it_should_behave_like "all valid sanitized files that are stored on disk"
|
339
|
-
|
340
|
-
describe '#path' do
|
341
|
-
it "should return the path of the tempfile" do
|
342
|
-
@sanitized_file.path.should_not be_nil
|
343
|
-
@sanitized_file.path.should == @hash["tempfile"].path
|
344
|
-
end
|
345
|
-
end
|
346
|
-
|
347
|
-
describe '#is_path?' do
|
348
|
-
it "should be false" do
|
349
|
-
@sanitized_file.is_path?.should be_false
|
350
|
-
end
|
351
|
-
end
|
352
|
-
|
353
|
-
end
|
354
|
-
|
355
|
-
describe "with a valid Tempfile" do
|
356
|
-
before do
|
357
|
-
@tempfile = stub_tempfile('llama.jpg', 'image/jpeg')
|
358
|
-
@sanitized_file = CarrierWave::SanitizedFile.new(@tempfile)
|
359
|
-
end
|
360
|
-
|
361
|
-
it_should_behave_like "all valid sanitized files"
|
362
|
-
|
363
|
-
it_should_behave_like "all valid sanitized files that are stored on disk"
|
364
|
-
|
365
|
-
describe '#is_path?' do
|
366
|
-
it "should be false" do
|
367
|
-
@sanitized_file.is_path?.should be_false
|
368
|
-
end
|
369
|
-
end
|
370
|
-
|
371
|
-
describe '#path' do
|
372
|
-
it "should return the path of the tempfile" do
|
373
|
-
@sanitized_file.path.should_not be_nil
|
374
|
-
@sanitized_file.path.should == @tempfile.path
|
375
|
-
end
|
376
|
-
end
|
377
|
-
|
378
|
-
end
|
379
|
-
|
380
|
-
describe "with a valid StringIO" do
|
381
|
-
before do
|
382
|
-
@sanitized_file = CarrierWave::SanitizedFile.new(stub_stringio('llama.jpg', 'image/jpeg'))
|
383
|
-
end
|
384
|
-
|
385
|
-
it_should_behave_like "all valid sanitized files"
|
386
|
-
|
387
|
-
describe '#exists?' do
|
388
|
-
it "should be false" do
|
389
|
-
@sanitized_file.exists?.should be_false
|
390
|
-
end
|
391
|
-
end
|
392
|
-
|
393
|
-
describe '#is_path?' do
|
394
|
-
it "should be false" do
|
395
|
-
@sanitized_file.is_path?.should be_false
|
396
|
-
end
|
397
|
-
end
|
398
|
-
|
399
|
-
describe '#path' do
|
400
|
-
it "should be nil" do
|
401
|
-
@sanitized_file.path.should be_nil
|
402
|
-
end
|
403
|
-
end
|
404
|
-
|
405
|
-
describe '#delete' do
|
406
|
-
it "should not raise an error" do
|
407
|
-
running { @sanitized_file.delete }.should_not raise_error
|
408
|
-
end
|
409
|
-
end
|
410
|
-
|
411
|
-
end
|
412
|
-
|
413
|
-
describe "with a valid File object" do
|
414
|
-
before do
|
415
|
-
FileUtils.cp(file_path('test.jpg'), file_path('llama.jpg'))
|
416
|
-
@sanitized_file = CarrierWave::SanitizedFile.new(stub_file('llama.jpg', 'image/jpeg'))
|
417
|
-
@sanitized_file.should_not be_empty
|
418
|
-
end
|
419
|
-
|
420
|
-
it_should_behave_like "all valid sanitized files"
|
421
|
-
|
422
|
-
it_should_behave_like "all valid sanitized files that are stored on disk"
|
423
|
-
|
424
|
-
describe '#is_path?' do
|
425
|
-
it "should be false" do
|
426
|
-
@sanitized_file.is_path?.should be_false
|
427
|
-
end
|
428
|
-
end
|
429
|
-
|
430
|
-
describe '#path' do
|
431
|
-
it "should return the path of the file" do
|
432
|
-
@sanitized_file.path.should_not be_nil
|
433
|
-
@sanitized_file.path.should == file_path('llama.jpg')
|
434
|
-
end
|
435
|
-
end
|
436
|
-
|
437
|
-
end
|
438
|
-
|
439
|
-
describe "with a valid path" do
|
440
|
-
before do
|
441
|
-
FileUtils.cp(file_path('test.jpg'), file_path('llama.jpg'))
|
442
|
-
@sanitized_file = CarrierWave::SanitizedFile.new(file_path('llama.jpg'))
|
443
|
-
@sanitized_file.should_not be_empty
|
444
|
-
end
|
445
|
-
|
446
|
-
it_should_behave_like "all valid sanitized files"
|
447
|
-
|
448
|
-
it_should_behave_like "all valid sanitized files that are stored on disk"
|
449
|
-
|
450
|
-
describe '#is_path?' do
|
451
|
-
it "should be true" do
|
452
|
-
@sanitized_file.is_path?.should be_true
|
453
|
-
end
|
454
|
-
end
|
455
|
-
|
456
|
-
describe '#path' do
|
457
|
-
it "should return the path of the file" do
|
458
|
-
@sanitized_file.path.should_not be_nil
|
459
|
-
@sanitized_file.path.should == file_path('llama.jpg')
|
460
|
-
end
|
461
|
-
end
|
462
|
-
|
463
|
-
end
|
464
|
-
|
465
|
-
describe "with a valid Pathname" do
|
466
|
-
before do
|
467
|
-
FileUtils.copy_file(file_path('test.jpg'), file_path('llama.jpg'))
|
468
|
-
@sanitized_file = CarrierWave::SanitizedFile.new(Pathname.new(file_path('llama.jpg')))
|
469
|
-
@sanitized_file.should_not be_empty
|
470
|
-
end
|
471
|
-
|
472
|
-
it_should_behave_like "all valid sanitized files"
|
473
|
-
|
474
|
-
it_should_behave_like "all valid sanitized files that are stored on disk"
|
475
|
-
|
476
|
-
describe '#is_path?' do
|
477
|
-
it "should be true" do
|
478
|
-
@sanitized_file.is_path?.should be_true
|
479
|
-
end
|
480
|
-
end
|
481
|
-
|
482
|
-
describe '#path' do
|
483
|
-
it "should return the path of the file" do
|
484
|
-
@sanitized_file.path.should_not be_nil
|
485
|
-
@sanitized_file.path.should == file_path('llama.jpg')
|
486
|
-
end
|
487
|
-
end
|
488
|
-
|
489
|
-
end
|
490
|
-
|
491
|
-
describe "that is empty" do
|
492
|
-
before do
|
493
|
-
@empty = CarrierWave::SanitizedFile.new(nil)
|
494
|
-
end
|
495
|
-
|
496
|
-
describe '#empty?' do
|
497
|
-
it "should be true" do
|
498
|
-
@empty.should be_empty
|
499
|
-
end
|
500
|
-
end
|
501
|
-
|
502
|
-
describe '#exists?' do
|
503
|
-
it "should be false" do
|
504
|
-
@empty.exists?.should be_false
|
505
|
-
end
|
506
|
-
end
|
507
|
-
|
508
|
-
describe '#is_path?' do
|
509
|
-
it "should be false" do
|
510
|
-
@empty.is_path?.should be_false
|
511
|
-
end
|
512
|
-
end
|
513
|
-
|
514
|
-
describe '#size' do
|
515
|
-
it "should be zero" do
|
516
|
-
@empty.size.should be_zero
|
517
|
-
end
|
518
|
-
end
|
519
|
-
|
520
|
-
describe '#path' do
|
521
|
-
it "should be nil" do
|
522
|
-
@empty.path.should be_nil
|
523
|
-
end
|
524
|
-
end
|
525
|
-
|
526
|
-
describe '#original_filename' do
|
527
|
-
it "should be nil" do
|
528
|
-
@empty.original_filename.should be_nil
|
529
|
-
end
|
530
|
-
end
|
531
|
-
|
532
|
-
describe '#filename' do
|
533
|
-
it "should be nil" do
|
534
|
-
@empty.filename.should be_nil
|
535
|
-
end
|
536
|
-
end
|
537
|
-
|
538
|
-
describe '#basename' do
|
539
|
-
it "should be nil" do
|
540
|
-
@empty.basename.should be_nil
|
541
|
-
end
|
542
|
-
end
|
543
|
-
|
544
|
-
describe '#extension' do
|
545
|
-
it "should be nil" do
|
546
|
-
@empty.extension.should be_nil
|
547
|
-
end
|
548
|
-
end
|
549
|
-
|
550
|
-
describe '#delete' do
|
551
|
-
it "should not raise an error" do
|
552
|
-
running { @empty.delete }.should_not raise_error
|
553
|
-
end
|
554
|
-
end
|
555
|
-
end
|
556
|
-
|
557
|
-
describe "that is an empty string" do
|
558
|
-
before do
|
559
|
-
@empty = CarrierWave::SanitizedFile.new("")
|
560
|
-
end
|
561
|
-
|
562
|
-
describe '#empty?' do
|
563
|
-
it "should be true" do
|
564
|
-
@empty.should be_empty
|
565
|
-
end
|
566
|
-
end
|
567
|
-
|
568
|
-
describe '#exists?' do
|
569
|
-
it "should be false" do
|
570
|
-
@empty.exists?.should be_false
|
571
|
-
end
|
572
|
-
end
|
573
|
-
|
574
|
-
describe '#is_path?' do
|
575
|
-
it "should be false" do
|
576
|
-
@empty.is_path?.should be_false
|
577
|
-
end
|
578
|
-
end
|
579
|
-
|
580
|
-
describe '#size' do
|
581
|
-
it "should be zero" do
|
582
|
-
@empty.size.should be_zero
|
583
|
-
end
|
584
|
-
end
|
585
|
-
|
586
|
-
describe '#path' do
|
587
|
-
it "should be nil" do
|
588
|
-
@empty.path.should be_nil
|
589
|
-
end
|
590
|
-
end
|
591
|
-
|
592
|
-
describe '#original_filename' do
|
593
|
-
it "should be nil" do
|
594
|
-
@empty.original_filename.should be_nil
|
595
|
-
end
|
596
|
-
end
|
597
|
-
|
598
|
-
describe '#filename' do
|
599
|
-
it "should be nil" do
|
600
|
-
@empty.filename.should be_nil
|
601
|
-
end
|
602
|
-
end
|
603
|
-
|
604
|
-
describe '#basename' do
|
605
|
-
it "should be nil" do
|
606
|
-
@empty.basename.should be_nil
|
607
|
-
end
|
608
|
-
end
|
609
|
-
|
610
|
-
describe '#extension' do
|
611
|
-
it "should be nil" do
|
612
|
-
@empty.extension.should be_nil
|
613
|
-
end
|
614
|
-
end
|
615
|
-
|
616
|
-
describe '#delete' do
|
617
|
-
it "should not raise an error" do
|
618
|
-
running { @empty.delete }.should_not raise_error
|
619
|
-
end
|
620
|
-
end
|
621
|
-
end
|
622
|
-
|
623
|
-
end
|