durran-carrierwave 0.3.2.3 → 0.4.3

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.
Files changed (67) hide show
  1. data/Generators +1 -1
  2. data/History.txt +39 -2
  3. data/Manifest.txt +19 -5
  4. data/README.rdoc +180 -55
  5. data/Rakefile +11 -4
  6. data/features/grid_fs_storage.feature +32 -0
  7. data/features/step_definitions/general_steps.rb +6 -1
  8. data/features/support/activerecord.rb +1 -1
  9. data/features/support/env.rb +3 -16
  10. data/lib/carrierwave.rb +19 -74
  11. data/lib/carrierwave/compatibility/paperclip.rb +2 -2
  12. data/lib/carrierwave/core_ext/inheritable_attributes.rb +3 -3
  13. data/lib/carrierwave/mount.rb +36 -27
  14. data/lib/carrierwave/orm/activerecord.rb +3 -3
  15. data/lib/carrierwave/orm/datamapper.rb +2 -2
  16. data/lib/carrierwave/orm/mongoid.rb +23 -0
  17. data/lib/carrierwave/orm/mongomapper.rb +1 -1
  18. data/lib/carrierwave/orm/sequel.rb +4 -16
  19. data/lib/carrierwave/processing/image_science.rb +54 -25
  20. data/lib/carrierwave/processing/mini_magick.rb +269 -0
  21. data/lib/carrierwave/processing/rmagick.rb +4 -6
  22. data/lib/carrierwave/sanitized_file.rb +7 -6
  23. data/lib/carrierwave/storage/abstract.rb +0 -2
  24. data/lib/carrierwave/storage/file.rb +3 -5
  25. data/lib/carrierwave/storage/grid_fs.rb +92 -0
  26. data/lib/carrierwave/storage/right_s3.rb +183 -0
  27. data/lib/carrierwave/storage/s3.rb +37 -69
  28. data/lib/carrierwave/test/matchers.rb +22 -8
  29. data/lib/carrierwave/uploader.rb +2 -2
  30. data/lib/carrierwave/uploader/cache.rb +21 -18
  31. data/lib/carrierwave/uploader/configuration.rb +122 -0
  32. data/lib/carrierwave/uploader/default_url.rb +19 -0
  33. data/lib/carrierwave/uploader/processing.rb +4 -2
  34. data/lib/carrierwave/uploader/remove.rb +0 -1
  35. data/lib/carrierwave/uploader/store.rb +1 -68
  36. data/lib/carrierwave/uploader/url.rb +1 -1
  37. data/lib/carrierwave/uploader/versions.rb +3 -4
  38. data/{lib/generators → merb_generators}/uploader_generator.rb +0 -0
  39. data/rails_generators/uploader/templates/uploader.rb +4 -4
  40. data/spec/compatibility/paperclip_spec.rb +11 -2
  41. data/spec/fixtures/landscape.jpg +0 -0
  42. data/spec/fixtures/portrait.jpg +0 -0
  43. data/spec/mount_spec.rb +0 -25
  44. data/spec/orm/datamapper_spec.rb +55 -48
  45. data/spec/orm/mongoid_spec.rb +206 -0
  46. data/spec/orm/mongomapper_spec.rb +19 -1
  47. data/spec/orm/sequel_spec.rb +3 -12
  48. data/spec/processing/image_science_spec.rb +56 -0
  49. data/spec/processing/mini_magick_spec.rb +76 -0
  50. data/spec/processing/rmagick_spec.rb +68 -0
  51. data/spec/sanitized_file_spec.rb +84 -74
  52. data/spec/spec_helper.rb +1 -3
  53. data/spec/storage/grid_fs_spec.rb +78 -0
  54. data/spec/storage/right_s3_spec.rb +75 -0
  55. data/spec/storage/s3_spec.rb +83 -0
  56. data/spec/uploader/cache_spec.rb +1 -13
  57. data/spec/uploader/configuration_spec.rb +105 -0
  58. data/spec/uploader/{default_path_spec.rb → default_url_spec.rb} +22 -5
  59. data/spec/uploader/paths_spec.rb +1 -1
  60. data/spec/uploader/processing_spec.rb +11 -0
  61. data/spec/uploader/store_spec.rb +21 -47
  62. data/spec/uploader/versions_spec.rb +0 -8
  63. metadata +105 -17
  64. data/LICENSE +0 -8
  65. data/carrierwave.gemspec +0 -57
  66. data/lib/carrierwave/uploader/default_path.rb +0 -23
  67. data/lib/carrierwave/uploader/paths.rb +0 -27
@@ -164,7 +164,7 @@ describe CarrierWave::MongoMapper do
164
164
  @doc = @class.new
165
165
  end
166
166
 
167
- context "when file assigned" do
167
+ describe "when file assigned" do
168
168
 
169
169
  it "removes the file from the filesystem" do
170
170
  @doc.image = stub_file('test.jpeg')
@@ -178,6 +178,24 @@ describe CarrierWave::MongoMapper do
178
178
 
179
179
  end
180
180
 
181
+ describe "when file is not assigned" do
182
+
183
+ it "deletes the instance of @class after save" do
184
+ @doc.save
185
+ @class.count.should eql(1)
186
+ @doc.destroy
187
+ end
188
+
189
+ it "deletes the instance of @class after save and then re-looking up the instance" do
190
+ # this fails with TypeError in 'CarrierWave::MongoMapper#destroy when file is not assigned deletes the instance of @class' can't modify frozen object
191
+ @doc.save
192
+ @class.count.should eql(1)
193
+ @doc = @class.first
194
+ @doc.destroy
195
+ end
196
+
197
+ end
198
+
181
199
  end
182
200
 
183
201
 
@@ -111,18 +111,9 @@ describe CarrierWave::Sequel do
111
111
  describe 'with validation' do
112
112
 
113
113
  before do
114
- # Add validations
115
- if CarrierWave::Sequel.new_sequel?
116
- @class.class_eval do
117
- def validate
118
- errors.add(:image, 'FAIL!')
119
- end
120
- end
121
- else
122
- @class.class_eval do
123
- validates_each(:image) do |o,a,v|
124
- o.errors.add(a, 'FAIL!')
125
- end
114
+ @class.class_eval do
115
+ def validate
116
+ errors.add(:image, 'FAIL!')
126
117
  end
127
118
  end
128
119
  # Turn off raising the exceptions on save
@@ -0,0 +1,56 @@
1
+ # encoding: utf-8
2
+
3
+ require File.dirname(__FILE__) + '/../spec_helper'
4
+
5
+ describe CarrierWave::ImageScience do
6
+
7
+ before do
8
+ @klass = Class.new do
9
+ include CarrierWave::ImageScience
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 '#resize_to_fill' do
21
+ it "should resize the image to exactly the given dimensions" do
22
+ @instance.resize_to_fill(200, 200)
23
+ @instance.should have_dimensions(200, 200)
24
+ end
25
+
26
+ it "should scale up the image if it smaller than the given dimensions" do
27
+ @instance.resize_to_fill(1000, 1000)
28
+ @instance.should have_dimensions(1000, 1000)
29
+ end
30
+ end
31
+
32
+ describe '#resize_to_fit' do
33
+ it "should resize the image to fit within the given dimensions" do
34
+ @instance.resize_to_fit(200, 200)
35
+ @instance.should have_dimensions(200, 150)
36
+ end
37
+
38
+ it "should scale up the image if it smaller than the given dimensions" do
39
+ @instance.resize_to_fit(1000, 1000)
40
+ @instance.should have_dimensions(1000, 750)
41
+ end
42
+ end
43
+
44
+ describe '#resize_to_limit' do
45
+ it "should resize the image to fit within the given dimensions" do
46
+ @instance.resize_to_limit(200, 200)
47
+ @instance.should have_dimensions(200, 150)
48
+ end
49
+
50
+ it "should not scale up the image if it smaller than the given dimensions" do
51
+ @instance.resize_to_limit(1000, 1000)
52
+ @instance.should have_dimensions(640, 480)
53
+ end
54
+ end
55
+
56
+ end
@@ -0,0 +1,76 @@
1
+ # encoding: utf-8
2
+
3
+ require File.dirname(__FILE__) + '/../spec_helper'
4
+
5
+ describe CarrierWave::MiniMagick do
6
+
7
+ before do
8
+ @klass = Class.new do
9
+ include CarrierWave::MiniMagick
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 from one format to another" do
22
+ @instance.convert('png')
23
+ img = ::MiniMagick::Image.from_file(@instance.current_path)
24
+ img['format'].should =~ /PNG/
25
+ end
26
+ end
27
+
28
+ describe '#resize_to_fill' do
29
+ it "should resize the image to exactly the given dimensions" do
30
+ @instance.resize_to_fill(200, 200)
31
+ @instance.should have_dimensions(200, 200)
32
+ end
33
+
34
+ it "should scale up the image if it smaller than the given dimensions" do
35
+ @instance.resize_to_fill(1000, 1000)
36
+ @instance.should have_dimensions(1000, 1000)
37
+ end
38
+ end
39
+
40
+ describe '#resize_and_pad' do
41
+ it "should resize the image to exactly the given dimensions" do
42
+ @instance.resize_and_pad(200, 200)
43
+ @instance.should have_dimensions(200, 200)
44
+ end
45
+
46
+ it "should scale up the image if it smaller than the given dimensions" do
47
+ @instance.resize_and_pad(1000, 1000)
48
+ @instance.should have_dimensions(1000, 1000)
49
+ end
50
+ end
51
+
52
+ describe '#resize_to_fit' do
53
+ it "should resize the image to fit within the given dimensions" do
54
+ @instance.resize_to_fit(200, 200)
55
+ @instance.should have_dimensions(200, 150)
56
+ end
57
+
58
+ it "should scale up the image if it smaller than the given dimensions" do
59
+ @instance.resize_to_fit(1000, 1000)
60
+ @instance.should have_dimensions(1000, 750)
61
+ end
62
+ end
63
+
64
+ describe '#resize_to_limit' do
65
+ it "should resize the image to fit within the given dimensions" do
66
+ @instance.resize_to_limit(200, 200)
67
+ @instance.should have_dimensions(200, 150)
68
+ end
69
+
70
+ it "should not scale up the image if it smaller than the given dimensions" do
71
+ @instance.resize_to_limit(1000, 1000)
72
+ @instance.should have_dimensions(640, 480)
73
+ end
74
+ end
75
+
76
+ end
@@ -0,0 +1,68 @@
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 '#resize_to_fill' do
21
+ it "should resize the image to exactly the given dimensions" do
22
+ @instance.resize_to_fill(200, 200)
23
+ @instance.should have_dimensions(200, 200)
24
+ end
25
+
26
+ it "should scale up the image if it smaller than the given dimensions" do
27
+ @instance.resize_to_fill(1000, 1000)
28
+ @instance.should have_dimensions(1000, 1000)
29
+ end
30
+ end
31
+
32
+ describe '#resize_and_pad' do
33
+ it "should resize the image to exactly the given dimensions" do
34
+ @instance.resize_and_pad(200, 200)
35
+ @instance.should have_dimensions(200, 200)
36
+ end
37
+
38
+ it "should scale up the image if it smaller than the given dimensions" do
39
+ @instance.resize_and_pad(1000, 1000)
40
+ @instance.should have_dimensions(1000, 1000)
41
+ end
42
+ end
43
+
44
+ describe '#resize_to_fit' do
45
+ it "should resize the image to fit within the given dimensions" do
46
+ @instance.resize_to_fit(200, 200)
47
+ @instance.should have_dimensions(200, 150)
48
+ end
49
+
50
+ it "should scale up the image if it smaller than the given dimensions" do
51
+ @instance.resize_to_fit(1000, 1000)
52
+ @instance.should have_dimensions(1000, 750)
53
+ end
54
+ end
55
+
56
+ describe '#resize_to_limit' do
57
+ it "should resize the image to fit within the given dimensions" do
58
+ @instance.resize_to_limit(200, 200)
59
+ @instance.should have_dimensions(200, 150)
60
+ end
61
+
62
+ it "should not scale up the image if it smaller than the given dimensions" do
63
+ @instance.resize_to_limit(1000, 1000)
64
+ @instance.should have_dimensions(640, 480)
65
+ end
66
+ end
67
+
68
+ end
@@ -3,27 +3,27 @@
3
3
  require File.dirname(__FILE__) + '/spec_helper'
4
4
 
5
5
  describe CarrierWave::SanitizedFile do
6
-
6
+
7
7
  before do
8
8
  unless File.exists?(file_path('llama.jpg'))
9
9
  FileUtils.cp(file_path('test.jpg'), file_path('llama.jpg'))
10
10
  end
11
11
  end
12
-
12
+
13
13
  after(:all) do
14
14
  if File.exists?(file_path('llama.jpg'))
15
15
  FileUtils.rm(file_path('llama.jpg'))
16
16
  end
17
17
  FileUtils.rm_rf(public_path)
18
18
  end
19
-
19
+
20
20
  describe '#empty?' do
21
-
21
+
22
22
  it "should be empty for nil" do
23
23
  @sanitized_file = CarrierWave::SanitizedFile.new(nil)
24
24
  @sanitized_file.should be_empty
25
25
  end
26
-
26
+
27
27
  it "should be empty for an empty string" do
28
28
  @sanitized_file = CarrierWave::SanitizedFile.new("")
29
29
  @sanitized_file.should be_empty
@@ -33,106 +33,116 @@ describe CarrierWave::SanitizedFile do
33
33
  @sanitized_file = CarrierWave::SanitizedFile.new(StringIO.new(""))
34
34
  @sanitized_file.should be_empty
35
35
  end
36
-
36
+
37
37
  it "should be empty for a file with a zero size" do
38
38
  empty_file = mock('emptyfile')
39
39
  empty_file.should_receive(:size).at_least(:once).and_return(0)
40
40
  @sanitized_file = CarrierWave::SanitizedFile.new(empty_file)
41
41
  @sanitized_file.should be_empty
42
42
  end
43
-
43
+
44
44
  end
45
-
45
+
46
46
  describe '#original_filename' do
47
47
  it "should default to the original_filename" do
48
48
  file = mock('file', :original_filename => 'llama.jpg')
49
49
  sanitized_file = CarrierWave::SanitizedFile.new(file)
50
50
  sanitized_file.original_filename.should == "llama.jpg"
51
51
  end
52
-
52
+
53
53
  it "should defer to the base name of the path if original_filename is unavailable" do
54
54
  file = mock('file', :path => '/path/to/test.jpg')
55
55
  sanitized_file = CarrierWave::SanitizedFile.new(file)
56
56
  sanitized_file.original_filename.should == "test.jpg"
57
57
  end
58
-
58
+
59
59
  it "should be nil otherwise" do
60
60
  file = mock('file')
61
61
  sanitized_file = CarrierWave::SanitizedFile.new(file)
62
62
  sanitized_file.original_filename.should be_nil
63
63
  end
64
64
  end
65
-
65
+
66
66
  describe '#basename' do
67
67
  it "should return the basename for complicated extensions" do
68
68
  @sanitized_file = CarrierWave::SanitizedFile.new(file_path('complex.filename.tar.gz'))
69
69
  @sanitized_file.basename.should == "complex.filename"
70
70
  end
71
-
71
+
72
72
  it "should be the filename if the file has no extension" do
73
73
  @sanitized_file = CarrierWave::SanitizedFile.new(file_path('complex'))
74
74
  @sanitized_file.basename.should == "complex"
75
75
  end
76
76
  end
77
-
77
+
78
78
  describe '#extension' do
79
79
  it "should return the extension for complicated extensions" do
80
80
  @sanitized_file = CarrierWave::SanitizedFile.new(file_path('complex.filename.tar.gz'))
81
81
  @sanitized_file.extension.should == "tar.gz"
82
82
  end
83
-
83
+
84
+ it "should return the extension for real-world user file names" do
85
+ @sanitized_file = CarrierWave::SanitizedFile.new(file_path('Photo on 2009-12-01 at 11.12.jpg'))
86
+ @sanitized_file.extension.should == "jpg"
87
+ end
88
+
89
+ it "should return the extension for basic filenames" do
90
+ @sanitized_file = CarrierWave::SanitizedFile.new(file_path('something.png'))
91
+ @sanitized_file.extension.should == "png"
92
+ end
93
+
84
94
  it "should be an empty string if the file has no extension" do
85
95
  @sanitized_file = CarrierWave::SanitizedFile.new(file_path('complex'))
86
96
  @sanitized_file.extension.should == ""
87
97
  end
88
98
  end
89
-
99
+
90
100
  describe '#filename' do
91
-
101
+
92
102
  before do
93
103
  @sanitized_file = CarrierWave::SanitizedFile.new(nil)
94
104
  end
95
-
105
+
96
106
  it "should default to the original filename if it is valid" do
97
107
  @sanitized_file.should_receive(:original_filename).at_least(:once).and_return("llama.jpg")
98
108
  @sanitized_file.filename.should == "llama.jpg"
99
109
  end
100
-
110
+
101
111
  it "should remove illegal characters from a filename" do
102
112
  @sanitized_file.should_receive(:original_filename).at_least(:once).and_return("test-s,%&m#st?.jpg")
103
113
  @sanitized_file.filename.should == "test-s___m_st_.jpg"
104
114
  end
105
-
115
+
106
116
  it "should remove slashes from the filename" do
107
117
  @sanitized_file.should_receive(:original_filename).at_least(:once).and_return("../../very_tricky/foo.bar")
108
118
  @sanitized_file.filename.should_not =~ /[\\\/]/
109
119
  end
110
-
120
+
111
121
  it "should remove illegal characters if there is no extension" do
112
122
  @sanitized_file.should_receive(:original_filename).at_least(:once).and_return('`*foo')
113
123
  @sanitized_file.filename.should == "__foo"
114
124
  end
115
-
125
+
116
126
  it "should remove the path prefix on Windows" do
117
127
  @sanitized_file.should_receive(:original_filename).at_least(:once).and_return('c:\temp\foo.txt')
118
128
  @sanitized_file.filename.should == "foo.txt"
119
129
  end
120
-
130
+
121
131
  it "should make sure the *nix directory thingies can't be used as filenames" do
122
132
  @sanitized_file.should_receive(:original_filename).at_least(:once).and_return(".")
123
133
  @sanitized_file.filename.should == "_."
124
134
  end
125
-
135
+
126
136
  it "should downcase uppercase filenames" do
127
137
  @sanitized_file.should_receive(:original_filename).at_least(:once).and_return("DSC4056.JPG")
128
138
  @sanitized_file.filename.should == "dsc4056.jpg"
129
139
  end
130
-
140
+
131
141
  end
132
142
 
133
143
  shared_examples_for "all valid sanitized files" do
134
-
135
- describe '#empty?' do
144
+
145
+ describe '#empty?' do
136
146
  it "should not be empty" do
137
147
  @sanitized_file.should_not be_empty
138
148
  end
@@ -161,7 +171,7 @@ describe CarrierWave::SanitizedFile do
161
171
  @sanitized_file.extension.should == "jpg"
162
172
  end
163
173
  end
164
-
174
+
165
175
  describe "#read" do
166
176
  it "should return the contents of the file" do
167
177
  @sanitized_file.read.should == "this is stuff"
@@ -175,22 +185,22 @@ describe CarrierWave::SanitizedFile do
175
185
  end
176
186
 
177
187
  describe '#move_to' do
178
-
188
+
179
189
  after do
180
190
  FileUtils.rm(file_path('gurr.png'))
181
191
  end
182
-
192
+
183
193
  it "should be moved to the correct location" do
184
194
  @sanitized_file.move_to(file_path('gurr.png'))
185
-
195
+
186
196
  File.exists?( file_path('gurr.png') ).should be_true
187
197
  end
188
-
198
+
189
199
  it "should have changed its path when moved" do
190
200
  @sanitized_file.move_to(file_path('gurr.png'))
191
201
  @sanitized_file.path.should == file_path('gurr.png')
192
202
  end
193
-
203
+
194
204
  it "should have changed its filename when moved" do
195
205
  @sanitized_file.move_to(file_path('gurr.png'))
196
206
  @sanitized_file.filename.should == 'gurr.png'
@@ -200,46 +210,46 @@ describe CarrierWave::SanitizedFile do
200
210
  @sanitized_file.move_to(file_path('gurr.png'))
201
211
  @sanitized_file.basename.should == 'gurr'
202
212
  end
203
-
213
+
204
214
  it "should have changed its extension when moved" do
205
215
  @sanitized_file.move_to(file_path('gurr.png'))
206
216
  @sanitized_file.extension.should == 'png'
207
217
  end
208
-
218
+
209
219
  it "should set the right permissions" do
210
220
  @sanitized_file.move_to(file_path('gurr.png'), 0755)
211
221
  @sanitized_file.should have_permissions(0755)
212
222
  end
213
-
223
+
214
224
  end
215
-
225
+
216
226
  describe '#copy_to' do
217
-
227
+
218
228
  after do
219
229
  FileUtils.rm(file_path('gurr.png'))
220
230
  end
221
-
231
+
222
232
  it "should be copied to the correct location" do
223
233
  @sanitized_file.copy_to(file_path('gurr.png'))
224
234
 
225
235
  File.exists?( file_path('gurr.png') ).should be_true
226
-
236
+
227
237
  file_path('gurr.png').should be_identical_to(file_path('llama.jpg'))
228
238
  end
229
-
239
+
230
240
  it "should not have changed its path when copied" do
231
241
  running { @sanitized_file.copy_to(file_path('gurr.png')) }.should_not change(@sanitized_file, :path)
232
242
  end
233
-
243
+
234
244
  it "should not have changed its filename when copied" do
235
245
  running { @sanitized_file.copy_to(file_path('gurr.png')) }.should_not change(@sanitized_file, :filename)
236
246
  end
237
-
247
+
238
248
  it "should return an object of the same class when copied" do
239
249
  new_file = @sanitized_file.copy_to(file_path('gurr.png'))
240
250
  new_file.should be_an_instance_of(@sanitized_file.class)
241
251
  end
242
-
252
+
243
253
  it "should adjust the path of the object that is returned when copied" do
244
254
  new_file = @sanitized_file.copy_to(file_path('gurr.png'))
245
255
  new_file.path.should == file_path('gurr.png')
@@ -249,17 +259,17 @@ describe CarrierWave::SanitizedFile do
249
259
  new_file = @sanitized_file.copy_to(file_path('gurr.png'))
250
260
  new_file.filename.should == 'gurr.png'
251
261
  end
252
-
262
+
253
263
  it "should adjust the basename of the object that is returned when copied" do
254
264
  new_file = @sanitized_file.copy_to(file_path('gurr.png'))
255
265
  new_file.basename.should == 'gurr'
256
266
  end
257
-
267
+
258
268
  it "should adjust the extension of the object that is returned when copied" do
259
269
  new_file = @sanitized_file.copy_to(file_path('gurr.png'))
260
270
  new_file.extension.should == 'png'
261
271
  end
262
-
272
+
263
273
  it "should set the right permissions" do
264
274
  new_file = @sanitized_file.copy_to(file_path('gurr.png'), 0755)
265
275
  new_file.should have_permissions(0755)
@@ -268,7 +278,7 @@ describe CarrierWave::SanitizedFile do
268
278
  end
269
279
 
270
280
  end
271
-
281
+
272
282
  shared_examples_for "all valid sanitized files that are stored on disk" do
273
283
  describe '#move_to' do
274
284
  it "should not raise an error when moved to its own location" do
@@ -296,13 +306,13 @@ describe CarrierWave::SanitizedFile do
296
306
  File.exist?(new_file.path).should be_true
297
307
  end
298
308
  end
299
-
309
+
300
310
  describe '#exists?' do
301
311
  it "should be true" do
302
312
  @sanitized_file.exists?.should be_true
303
313
  end
304
314
  end
305
-
315
+
306
316
  describe '#delete' do
307
317
  it "should remove it from the filesystem" do
308
318
  File.exists?(@sanitized_file.path).should be_true
@@ -321,24 +331,24 @@ describe CarrierWave::SanitizedFile do
321
331
  }
322
332
  @sanitized_file = CarrierWave::SanitizedFile.new(@hash)
323
333
  end
324
-
334
+
325
335
  it_should_behave_like "all valid sanitized files"
326
336
 
327
337
  it_should_behave_like "all valid sanitized files that are stored on disk"
328
-
338
+
329
339
  describe '#path' do
330
340
  it "should return the path of the tempfile" do
331
341
  @sanitized_file.path.should_not be_nil
332
342
  @sanitized_file.path.should == @hash["tempfile"].path
333
343
  end
334
344
  end
335
-
345
+
336
346
  describe '#is_path?' do
337
347
  it "should be false" do
338
348
  @sanitized_file.is_path?.should be_false
339
349
  end
340
350
  end
341
-
351
+
342
352
  end
343
353
 
344
354
  describe "with a valid Tempfile" do
@@ -356,7 +366,7 @@ describe CarrierWave::SanitizedFile do
356
366
  @sanitized_file.is_path?.should be_false
357
367
  end
358
368
  end
359
-
369
+
360
370
  describe '#path' do
361
371
  it "should return the path of the tempfile" do
362
372
  @sanitized_file.path.should_not be_nil
@@ -370,15 +380,15 @@ describe CarrierWave::SanitizedFile do
370
380
  before do
371
381
  @sanitized_file = CarrierWave::SanitizedFile.new(stub_stringio('llama.jpg', 'image/jpeg'))
372
382
  end
373
-
383
+
374
384
  it_should_behave_like "all valid sanitized files"
375
-
385
+
376
386
  describe '#exists?' do
377
387
  it "should be false" do
378
388
  @sanitized_file.exists?.should be_false
379
389
  end
380
390
  end
381
-
391
+
382
392
  describe '#is_path?' do
383
393
  it "should be false" do
384
394
  @sanitized_file.is_path?.should be_false
@@ -390,13 +400,13 @@ describe CarrierWave::SanitizedFile do
390
400
  @sanitized_file.path.should be_nil
391
401
  end
392
402
  end
393
-
403
+
394
404
  describe '#delete' do
395
405
  it "should not raise an error" do
396
406
  running { @sanitized_file.delete }.should_not raise_error
397
407
  end
398
408
  end
399
-
409
+
400
410
  end
401
411
 
402
412
  describe "with a valid File object" do
@@ -405,9 +415,9 @@ describe CarrierWave::SanitizedFile do
405
415
  @sanitized_file = CarrierWave::SanitizedFile.new(stub_file('llama.jpg', 'image/jpeg'))
406
416
  @sanitized_file.should_not be_empty
407
417
  end
408
-
418
+
409
419
  it_should_behave_like "all valid sanitized files"
410
-
420
+
411
421
  it_should_behave_like "all valid sanitized files that are stored on disk"
412
422
 
413
423
  describe '#is_path?' do
@@ -431,9 +441,9 @@ describe CarrierWave::SanitizedFile do
431
441
  @sanitized_file = CarrierWave::SanitizedFile.new(file_path('llama.jpg'))
432
442
  @sanitized_file.should_not be_empty
433
443
  end
434
-
444
+
435
445
  it_should_behave_like "all valid sanitized files"
436
-
446
+
437
447
  it_should_behave_like "all valid sanitized files that are stored on disk"
438
448
 
439
449
  describe '#is_path?' do
@@ -441,7 +451,7 @@ describe CarrierWave::SanitizedFile do
441
451
  @sanitized_file.is_path?.should be_true
442
452
  end
443
453
  end
444
-
454
+
445
455
  describe '#path' do
446
456
  it "should return the path of the file" do
447
457
  @sanitized_file.path.should_not be_nil
@@ -450,14 +460,14 @@ describe CarrierWave::SanitizedFile do
450
460
  end
451
461
 
452
462
  end
453
-
463
+
454
464
  describe "with a valid Pathname" do
455
465
  before do
456
466
  FileUtils.copy_file(file_path('test.jpg'), file_path('llama.jpg'))
457
467
  @sanitized_file = CarrierWave::SanitizedFile.new(Pathname.new(file_path('llama.jpg')))
458
468
  @sanitized_file.should_not be_empty
459
469
  end
460
-
470
+
461
471
  it_should_behave_like "all valid sanitized files"
462
472
 
463
473
  it_should_behave_like "all valid sanitized files that are stored on disk"
@@ -467,7 +477,7 @@ describe CarrierWave::SanitizedFile do
467
477
  @sanitized_file.is_path?.should be_true
468
478
  end
469
479
  end
470
-
480
+
471
481
  describe '#path' do
472
482
  it "should return the path of the file" do
473
483
  @sanitized_file.path.should_not be_nil
@@ -487,7 +497,7 @@ describe CarrierWave::SanitizedFile do
487
497
  @empty.should be_empty
488
498
  end
489
499
  end
490
-
500
+
491
501
  describe '#exists?' do
492
502
  it "should be false" do
493
503
  @empty.exists?.should be_false
@@ -518,7 +528,7 @@ describe CarrierWave::SanitizedFile do
518
528
  end
519
529
  end
520
530
 
521
- describe '#filename' do
531
+ describe '#filename' do
522
532
  it "should be nil" do
523
533
  @empty.filename.should be_nil
524
534
  end
@@ -535,14 +545,14 @@ describe CarrierWave::SanitizedFile do
535
545
  @empty.extension.should be_nil
536
546
  end
537
547
  end
538
-
548
+
539
549
  describe '#delete' do
540
550
  it "should not raise an error" do
541
551
  running { @empty.delete }.should_not raise_error
542
552
  end
543
553
  end
544
554
  end
545
-
555
+
546
556
  describe "that is an empty string" do
547
557
  before do
548
558
  @empty = CarrierWave::SanitizedFile.new("")
@@ -584,7 +594,7 @@ describe CarrierWave::SanitizedFile do
584
594
  end
585
595
  end
586
596
 
587
- describe '#filename' do
597
+ describe '#filename' do
588
598
  it "should be nil" do
589
599
  @empty.filename.should be_nil
590
600
  end
@@ -608,5 +618,5 @@ describe CarrierWave::SanitizedFile do
608
618
  end
609
619
  end
610
620
  end
611
-
612
- end
621
+
622
+ end