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,105 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
4
|
-
|
5
|
-
|
6
|
-
describe CarrierWave do
|
7
|
-
before do
|
8
|
-
@uploader_class = Class.new(CarrierWave::Uploader::Base)
|
9
|
-
end
|
10
|
-
|
11
|
-
describe '.configure' do
|
12
|
-
it "should proxy to Uploader configuration" do
|
13
|
-
CarrierWave::Uploader::Base.add_config :test_config
|
14
|
-
CarrierWave.configure do |config|
|
15
|
-
config.test_config = "foo"
|
16
|
-
end
|
17
|
-
CarrierWave::Uploader::Base.test_config.should == 'foo'
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe CarrierWave::Uploader::Base do
|
23
|
-
before do
|
24
|
-
@uploader_class = Class.new(CarrierWave::Uploader::Base)
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '.configure' do
|
28
|
-
it "should set a configuration parameter" do
|
29
|
-
@uploader_class.add_config :foo_bar
|
30
|
-
@uploader_class.configure do |config|
|
31
|
-
config.foo_bar = "monkey"
|
32
|
-
end
|
33
|
-
@uploader_class.foo_bar.should == 'monkey'
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe ".storage" do
|
38
|
-
it "should set the storage if an argument is given" do
|
39
|
-
storage = mock('some kind of storage')
|
40
|
-
@uploader_class.storage storage
|
41
|
-
@uploader_class.storage.should == storage
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should default to file" do
|
45
|
-
@uploader_class.storage.should == CarrierWave::Storage::File
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should set the storage from the configured shortcuts if a symbol is given" do
|
49
|
-
@uploader_class.storage :file
|
50
|
-
@uploader_class.storage.should == CarrierWave::Storage::File
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should remember the storage when inherited" do
|
54
|
-
@uploader_class.storage :s3
|
55
|
-
subclass = Class.new(@uploader_class)
|
56
|
-
subclass.storage.should == CarrierWave::Storage::S3
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should be changeable when inherited" do
|
60
|
-
@uploader_class.storage :s3
|
61
|
-
subclass = Class.new(@uploader_class)
|
62
|
-
subclass.storage.should == CarrierWave::Storage::S3
|
63
|
-
subclass.storage :file
|
64
|
-
subclass.storage.should == CarrierWave::Storage::File
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
describe '.add_config' do
|
70
|
-
it "should add a class level accessor" do
|
71
|
-
@uploader_class.add_config :foo_bar
|
72
|
-
@uploader_class.foo_bar = 'foo'
|
73
|
-
@uploader_class.foo_bar.should == 'foo'
|
74
|
-
end
|
75
|
-
|
76
|
-
['foo', :foo, 45, ['foo', :bar]].each do |val|
|
77
|
-
it "should be inheritable for a #{val.class}" do
|
78
|
-
@uploader_class.add_config :foo_bar
|
79
|
-
@child_class = Class.new(@uploader_class)
|
80
|
-
|
81
|
-
@uploader_class.foo_bar = val
|
82
|
-
@uploader_class.foo_bar.should == val
|
83
|
-
@child_class.foo_bar.should == val
|
84
|
-
|
85
|
-
@child_class.foo_bar = "bar"
|
86
|
-
@child_class.foo_bar.should == "bar"
|
87
|
-
|
88
|
-
@uploader_class.foo_bar.should == val
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
|
93
|
-
it "should add an instance level accessor" do
|
94
|
-
@uploader_class.add_config :foo_bar
|
95
|
-
@uploader_class.foo_bar = 'foo'
|
96
|
-
@uploader_class.new.foo_bar.should == 'foo'
|
97
|
-
end
|
98
|
-
|
99
|
-
it "should add a convenient in-class setter" do
|
100
|
-
@uploader_class.add_config :foo_bar
|
101
|
-
@uploader_class.foo_bar "monkey"
|
102
|
-
@uploader_class.foo_bar.should == "monkey"
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
@@ -1,85 +0,0 @@
|
|
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 'with a default url' do
|
17
|
-
before do
|
18
|
-
@uploader_class.class_eval do
|
19
|
-
version :thumb
|
20
|
-
def default_url
|
21
|
-
["http://someurl.example.com", version_name].compact.join('/')
|
22
|
-
end
|
23
|
-
end
|
24
|
-
@uploader = @uploader_class.new
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '#blank?' do
|
28
|
-
it "should be true by default" do
|
29
|
-
@uploader.should be_blank
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '#current_path' do
|
34
|
-
it "should return nil" do
|
35
|
-
@uploader.current_path.should be_nil
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe '#url' do
|
40
|
-
it "should return the default url" do
|
41
|
-
@uploader.url.should == 'http://someurl.example.com'
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should return the default url with version when given" do
|
45
|
-
@uploader.url(:thumb).should == 'http://someurl.example.com/thumb'
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe '#cache!' do
|
50
|
-
|
51
|
-
before do
|
52
|
-
CarrierWave.stub!(:generate_cache_id).and_return('20071201-1234-345-2255')
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should cache a file" do
|
56
|
-
@uploader.cache!(File.open(file_path('test.jpg')))
|
57
|
-
@uploader.file.should be_an_instance_of(CarrierWave::SanitizedFile)
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should be cached" do
|
61
|
-
@uploader.cache!(File.open(file_path('test.jpg')))
|
62
|
-
@uploader.should be_cached
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should no longer be blank" do
|
66
|
-
@uploader.cache!(File.open(file_path('test.jpg')))
|
67
|
-
@uploader.should_not be_blank
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should set the current_path" do
|
71
|
-
@uploader.cache!(File.open(file_path('test.jpg')))
|
72
|
-
@uploader.current_path.should == public_path('uploads/tmp/20071201-1234-345-2255/test.jpg')
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should set the url" do
|
76
|
-
@uploader.cache!(File.open(file_path('test.jpg')))
|
77
|
-
@uploader.url.should_not == 'http://someurl.example.com'
|
78
|
-
@uploader.url.should == '/uploads/tmp/20071201-1234-345-2255/test.jpg'
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
4
|
-
|
5
|
-
describe CarrierWave::Uploader::Download 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 '#download!' do
|
17
|
-
|
18
|
-
before do
|
19
|
-
CarrierWave.stub!(:generate_cache_id).and_return('20071201-1234-345-2255')
|
20
|
-
response = mock('HTTP Response')
|
21
|
-
response.stub!(:body).and_return('Response Body')
|
22
|
-
Net::HTTP.stub!(:get_response).and_return(response)
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should cache a file" do
|
26
|
-
@uploader.download!('http://www.example.com/test/file.png')
|
27
|
-
@uploader.file.should be_an_instance_of(CarrierWave::SanitizedFile)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should be cached" do
|
31
|
-
@uploader.download!('http://www.example.com/test/file.png')
|
32
|
-
@uploader.should be_cached
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should store the cache name" do
|
36
|
-
@uploader.download!('http://www.example.com/test/file.png')
|
37
|
-
@uploader.cache_name.should == '20071201-1234-345-2255/file.png'
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should set the filename to the file's sanitized filename" do
|
41
|
-
@uploader.download!('http://www.example.com/test/file.png')
|
42
|
-
@uploader.filename.should == 'file.png'
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should move it to the tmp dir" do
|
46
|
-
@uploader.download!('http://www.example.com/test/file.png')
|
47
|
-
@uploader.file.path.should == public_path('uploads/tmp/20071201-1234-345-2255/file.png')
|
48
|
-
@uploader.file.exists?.should be_true
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should set the url" do
|
52
|
-
@uploader.download!('http://www.example.com/test/file.png')
|
53
|
-
@uploader.url.should == '/uploads/tmp/20071201-1234-345-2255/file.png'
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should do nothing when trying to download an empty file" do
|
57
|
-
@uploader.download!(nil)
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should set permissions if options are given" do
|
61
|
-
@uploader_class.permissions = 0777
|
62
|
-
|
63
|
-
@uploader.download!('http://www.example.com/test/file.png')
|
64
|
-
@uploader.should have_permissions(0777)
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should raise an error when trying to download a local file" do
|
68
|
-
running {
|
69
|
-
@uploader.download!('/etc/passwd')
|
70
|
-
}.should raise_error(CarrierWave::DownloadError)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
75
|
-
|
@@ -1,44 +0,0 @@
|
|
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 '#cache!' do
|
17
|
-
|
18
|
-
before do
|
19
|
-
CarrierWave.stub!(:generate_cache_id).and_return('20071201-1234-345-2255')
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should not raise an integiry error if there is no white list" do
|
23
|
-
@uploader.stub!(:extension_white_list).and_return(nil)
|
24
|
-
running {
|
25
|
-
@uploader.cache!(File.open(file_path('test.jpg')))
|
26
|
-
}.should_not raise_error(CarrierWave::IntegrityError)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should not raise an integiry error if there is a white list and the file is on it" do
|
30
|
-
@uploader.stub!(:extension_white_list).and_return(%w(jpg gif png))
|
31
|
-
running {
|
32
|
-
@uploader.cache!(File.open(file_path('test.jpg')))
|
33
|
-
}.should_not raise_error(CarrierWave::IntegrityError)
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should raise an integiry error if there is a white list and the file is not on it" do
|
37
|
-
@uploader.stub!(:extension_white_list).and_return(%w(txt doc xls))
|
38
|
-
running {
|
39
|
-
@uploader.cache!(File.open(file_path('test.jpg')))
|
40
|
-
}.should raise_error(CarrierWave::IntegrityError)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
@@ -1,33 +0,0 @@
|
|
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 '#model' do
|
17
|
-
it "should be remembered from initialization" do
|
18
|
-
model = mock('a model object')
|
19
|
-
@uploader = @uploader_class.new(model)
|
20
|
-
@uploader.model.should == model
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#mounted_as' do
|
25
|
-
it "should be remembered from initialization" do
|
26
|
-
model = mock('a model object')
|
27
|
-
@uploader = @uploader_class.new(model, :llama)
|
28
|
-
@uploader.model.should == model
|
29
|
-
@uploader.mounted_as.should == :llama
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
data/spec/uploader/paths_spec.rb
DELETED
@@ -1,22 +0,0 @@
|
|
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 '#root' do
|
17
|
-
it "should default to the config option" do
|
18
|
-
@uploader.root.should == public_path
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
@@ -1,73 +0,0 @@
|
|
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
|
-
|
50
|
-
context "with 'enable_processing' set to false" do
|
51
|
-
it "should not do any processing" do
|
52
|
-
@uploader_class.enable_processing = false
|
53
|
-
@uploader_class.process :sepiatone, :desaturate, :invert
|
54
|
-
@uploader.should_not_receive(:sepiatone)
|
55
|
-
@uploader.should_not_receive(:desaturate)
|
56
|
-
@uploader.should_not_receive(:invert)
|
57
|
-
@uploader.process!
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe '#cache!' do
|
63
|
-
before do
|
64
|
-
CarrierWave.stub!(:generate_cache_id).and_return('20071201-1234-345-2255')
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should trigger a process!" do
|
68
|
-
@uploader.should_receive(:process!)
|
69
|
-
@uploader.cache!(File.open(file_path('test.jpg')))
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
data/spec/uploader/proxy_spec.rb
DELETED
@@ -1,54 +0,0 @@
|
|
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
|