samlown-carrierwave 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Generators +4 -0
- data/History.txt +125 -0
- data/Manifest.txt +110 -0
- data/README.rdoc +524 -0
- data/Rakefile +39 -0
- data/carrierwave.gemspec +85 -0
- data/cucumber.yml +2 -0
- data/features/caching.feature +28 -0
- data/features/download.feature +20 -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/grid_fs_storage.feature +32 -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/download_steps.rb +4 -0
- data/features/step_definitions/file_steps.rb +53 -0
- data/features/step_definitions/general_steps.rb +85 -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 +22 -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 +98 -0
- data/lib/carrierwave/compatibility/paperclip.rb +95 -0
- data/lib/carrierwave/core_ext/blank.rb +46 -0
- data/lib/carrierwave/core_ext/file.rb +11 -0
- data/lib/carrierwave/core_ext/inheritable_attributes.rb +108 -0
- data/lib/carrierwave/core_ext/module_setup.rb +51 -0
- data/lib/carrierwave/mount.rb +359 -0
- data/lib/carrierwave/orm/activerecord.rb +73 -0
- data/lib/carrierwave/orm/datamapper.rb +27 -0
- data/lib/carrierwave/orm/mongoid.rb +23 -0
- data/lib/carrierwave/orm/mongomapper.rb +27 -0
- data/lib/carrierwave/orm/sequel.rb +45 -0
- data/lib/carrierwave/processing/image_science.rb +101 -0
- data/lib/carrierwave/processing/mini_magick.rb +265 -0
- data/lib/carrierwave/processing/rmagick.rb +282 -0
- data/lib/carrierwave/sanitized_file.rb +273 -0
- data/lib/carrierwave/storage/abstract.rb +30 -0
- data/lib/carrierwave/storage/cloud_files.rb +169 -0
- data/lib/carrierwave/storage/file.rb +48 -0
- data/lib/carrierwave/storage/grid_fs.rb +97 -0
- data/lib/carrierwave/storage/right_s3.rb +3 -0
- data/lib/carrierwave/storage/s3.rb +206 -0
- data/lib/carrierwave/test/matchers.rb +128 -0
- data/lib/carrierwave/uploader.rb +44 -0
- data/lib/carrierwave/uploader/cache.rb +145 -0
- data/lib/carrierwave/uploader/callbacks.rb +42 -0
- data/lib/carrierwave/uploader/configuration.rb +132 -0
- data/lib/carrierwave/uploader/default_url.rb +19 -0
- data/lib/carrierwave/uploader/download.rb +59 -0
- data/lib/carrierwave/uploader/extension_whitelist.rb +37 -0
- data/lib/carrierwave/uploader/mountable.rb +39 -0
- data/lib/carrierwave/uploader/processing.rb +83 -0
- data/lib/carrierwave/uploader/proxy.rb +62 -0
- data/lib/carrierwave/uploader/remove.rb +22 -0
- data/lib/carrierwave/uploader/store.rb +89 -0
- data/lib/carrierwave/uploader/url.rb +33 -0
- data/lib/carrierwave/uploader/versions.rb +146 -0
- data/merb_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 +52 -0
- data/spec/fixtures/bork.txt +1 -0
- data/spec/fixtures/landscape.jpg +0 -0
- data/spec/fixtures/portrait.jpg +0 -0
- data/spec/fixtures/test.jpeg +1 -0
- data/spec/fixtures/test.jpg +1 -0
- data/spec/mount_spec.rb +538 -0
- data/spec/orm/activerecord_spec.rb +271 -0
- data/spec/orm/datamapper_spec.rb +168 -0
- data/spec/orm/mongoid_spec.rb +202 -0
- data/spec/orm/mongomapper_spec.rb +202 -0
- data/spec/orm/sequel_spec.rb +183 -0
- data/spec/processing/image_science_spec.rb +56 -0
- data/spec/processing/mini_magick_spec.rb +76 -0
- data/spec/processing/rmagick_spec.rb +75 -0
- data/spec/sanitized_file_spec.rb +623 -0
- data/spec/spec_helper.rb +92 -0
- data/spec/storage/cloudfiles_spec.rb +78 -0
- data/spec/storage/grid_fs_spec.rb +83 -0
- data/spec/storage/s3_spec.rb +118 -0
- data/spec/uploader/cache_spec.rb +209 -0
- data/spec/uploader/configuration_spec.rb +105 -0
- data/spec/uploader/default_url_spec.rb +85 -0
- data/spec/uploader/download_spec.rb +75 -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 +73 -0
- data/spec/uploader/proxy_spec.rb +54 -0
- data/spec/uploader/remove_spec.rb +70 -0
- data/spec/uploader/store_spec.rb +264 -0
- data/spec/uploader/url_spec.rb +102 -0
- data/spec/uploader/versions_spec.rb +298 -0
- metadata +433 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Given /^an activerecord class that uses the '([^\']*)' table$/ do |name|
|
4
|
+
@mountee_klass = Class.new(ActiveRecord::Base)
|
5
|
+
@mountee_klass.table_name = name
|
6
|
+
end
|
7
|
+
|
8
|
+
Given /^an instance of the activerecord class$/ do
|
9
|
+
@instance = @mountee_klass.new
|
10
|
+
end
|
11
|
+
|
12
|
+
When /^I save the active record$/ do
|
13
|
+
@instance.save!
|
14
|
+
end
|
15
|
+
|
16
|
+
When /^I reload the active record$/ do
|
17
|
+
@instance = @instance.class.find(@instance.id)
|
18
|
+
end
|
19
|
+
|
20
|
+
When /^I delete the active record$/ do
|
21
|
+
@instance.destroy
|
22
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Given /^the file '(.*?)' is cached file at '(.*?)'$/ do |file, cached|
|
4
|
+
FileUtils.mkdir_p(File.dirname(file_path(cached)))
|
5
|
+
FileUtils.cp(file_path(file), file_path(cached))
|
6
|
+
end
|
7
|
+
|
8
|
+
When /^I cache the file '(.*?)'$/ do |file|
|
9
|
+
@uploader.cache!(File.open(file_path(file)))
|
10
|
+
end
|
11
|
+
|
12
|
+
When /^I retrieve the cache name '(.*?)' from the cache$/ do |name|
|
13
|
+
@uploader.retrieve_from_cache!(name)
|
14
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Given /^a datamapper class that has a '([^\']*)' column$/ do |column|
|
4
|
+
@mountee_klass = Class.new do
|
5
|
+
include DataMapper::Resource
|
6
|
+
|
7
|
+
storage_names[:default] = 'users'
|
8
|
+
|
9
|
+
property :id, Integer, :key => true
|
10
|
+
property column.to_sym, String
|
11
|
+
end
|
12
|
+
@mountee_klass.auto_migrate!
|
13
|
+
end
|
14
|
+
|
15
|
+
Given /^an instance of the datamapper class$/ do
|
16
|
+
@instance = @mountee_klass.new
|
17
|
+
end
|
18
|
+
|
19
|
+
When /^I save the datamapper record$/ do
|
20
|
+
@instance.save
|
21
|
+
end
|
22
|
+
|
23
|
+
When /^I reload the datamapper record$/ do
|
24
|
+
@instance = @instance.class.first(:id => @instance.key)
|
25
|
+
end
|
26
|
+
|
27
|
+
When /^I delete the datamapper record$/ do
|
28
|
+
@instance.destroy
|
29
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# EXISTENCE
|
5
|
+
|
6
|
+
Then /^there should be a file at '(.*?)'$/ do |file|
|
7
|
+
File.exist?(file_path(file)).should be_true
|
8
|
+
end
|
9
|
+
|
10
|
+
Then /^there should not be a file at '(.*?)'$/ do |file|
|
11
|
+
File.exist?(file_path(file)).should be_false
|
12
|
+
end
|
13
|
+
|
14
|
+
Then /^there should be a file called '(.*?)' somewhere in a subdirectory of '(.*?)'$/ do |file, directory|
|
15
|
+
Dir.glob(File.join(file_path(directory), '**', file)).any?.should be_true
|
16
|
+
end
|
17
|
+
|
18
|
+
###
|
19
|
+
# IDENTICAL
|
20
|
+
|
21
|
+
Then /^the file at '(.*?)' should be identical to the file at '(.*?)'$/ do |one, two|
|
22
|
+
File.read(file_path(one)).should == File.read(file_path(two))
|
23
|
+
end
|
24
|
+
|
25
|
+
Then /^the file at '(.*?)' should not be identical to the file at '(.*?)'$/ do |one, two|
|
26
|
+
File.read(file_path(one)).should_not == File.read(file_path(two))
|
27
|
+
end
|
28
|
+
|
29
|
+
Then /^the file called '(.*?)' in a subdirectory of '(.*?)' should be identical to the file at '(.*?)'$/ do |file, directory, other|
|
30
|
+
File.read(Dir.glob(File.join(file_path(directory), '**', file)).first).should == File.read(file_path(other))
|
31
|
+
end
|
32
|
+
|
33
|
+
Then /^the file called '(.*?)' in a subdirectory of '(.*?)' should not be identical to the file at '(.*?)'$/ do |file, directory, other|
|
34
|
+
File.read(Dir.glob(File.join(file_path(directory), '**', file)).first).should_not == File.read(file_path(other))
|
35
|
+
end
|
36
|
+
|
37
|
+
###
|
38
|
+
# CONTENT
|
39
|
+
|
40
|
+
Then /^the file called '([^']+)' in a subdirectory of '([^']+)' should contain '([^']+)'$/ do |file, directory, content|
|
41
|
+
File.read(Dir.glob(File.join(file_path(directory), '**', file)).first).should include(content)
|
42
|
+
end
|
43
|
+
|
44
|
+
Then /^the file at '([^']+)' should contain '([^']+)'$/ do |path, content|
|
45
|
+
File.read(file_path(path)).should include(content)
|
46
|
+
end
|
47
|
+
|
48
|
+
###
|
49
|
+
# REVERSING
|
50
|
+
|
51
|
+
Then /^the file at '(.*?)' should be the reverse of the file at '(.*?)'$/ do |one, two|
|
52
|
+
File.read(file_path(one)).should == File.read(file_path(two)).reverse
|
53
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Given /^an uploader class that uses the '(.*?)' storage$/ do |kind|
|
4
|
+
@klass = Class.new(CarrierWave::Uploader::Base)
|
5
|
+
@klass.storage = kind.to_sym
|
6
|
+
end
|
7
|
+
|
8
|
+
Given /^an instance of that class$/ do
|
9
|
+
@uploader = @klass.new
|
10
|
+
end
|
11
|
+
|
12
|
+
Then /^the contents of the file should be '(.*?)'$/ do |contents|
|
13
|
+
@uploader.read.chomp.should == contents
|
14
|
+
end
|
15
|
+
|
16
|
+
Given /^that the uploader reverses the filename$/ do
|
17
|
+
@klass.class_eval do
|
18
|
+
def filename
|
19
|
+
super.reverse unless super.blank?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
Given /^that the uploader has the filename overridden to '(.*?)'$/ do |filename|
|
25
|
+
@klass.class_eval do
|
26
|
+
define_method(:filename) do
|
27
|
+
filename
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
Given /^that the uploader has the store_dir overridden to '(.*?)'$/ do |store_dir|
|
33
|
+
@klass.class_eval do
|
34
|
+
define_method(:store_dir) do
|
35
|
+
file_path(store_dir)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
Given /^that the version '(.*?)' has the store_dir overridden to '(.*?)'$/ do |version, store_dir|
|
41
|
+
@klass.versions[version.to_sym].class_eval do
|
42
|
+
define_method(:store_dir) do
|
43
|
+
file_path(store_dir)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
Given /^that the uploader class has a version named '(.*?)'$/ do |name|
|
49
|
+
@klass.version(name)
|
50
|
+
end
|
51
|
+
|
52
|
+
Given /^yo dawg, I put a version called '(.*?)' in your version called '(.*?)'$/ do |v2, v1|
|
53
|
+
@klass.version(v1) do
|
54
|
+
version(v2)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
Given /^the class has a method called 'reverse' that reverses the contents of a file$/ do
|
59
|
+
@klass.class_eval do
|
60
|
+
def reverse
|
61
|
+
text = File.read(current_path)
|
62
|
+
File.open(current_path, 'w') { |f| f.write(text.reverse) }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
Given /^the class will process '([a-zA-Z0-9\_\?!]*)'$/ do |name|
|
68
|
+
@klass.process name.to_sym
|
69
|
+
end
|
70
|
+
|
71
|
+
Then /^the uploader should have '(.*?)' as its current path$/ do |path|
|
72
|
+
@uploader.current_path.should == file_path(path)
|
73
|
+
end
|
74
|
+
|
75
|
+
Then /^the uploader should have the url '(.*?)'$/ do |url|
|
76
|
+
@uploader.url.should == url
|
77
|
+
end
|
78
|
+
|
79
|
+
Then /^the uploader's version '(.*?)' should have the url '(.*?)'$/ do |version, url|
|
80
|
+
@uploader.versions[version.to_sym].url.should == url
|
81
|
+
end
|
82
|
+
|
83
|
+
Then /^the uploader's nested version '(.*?)' nested in '(.*?)' should have the url '(.*?)'$/ do |v2, v1, url|
|
84
|
+
@uploader.versions[v1.to_sym].versions[v2.to_sym].url.should == url
|
85
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
When /^I assign the file '([^\']*)' to the '([^\']*)' column$/ do |path, column|
|
4
|
+
@instance.send("#{column}=", File.open(file_path(path)))
|
5
|
+
end
|
6
|
+
|
7
|
+
Given /^the uploader class is mounted on the '([^\']*)' column$/ do |column|
|
8
|
+
@mountee_klass.mount_uploader column.to_sym, @klass
|
9
|
+
end
|
10
|
+
|
11
|
+
When /^I retrieve the file later from the cache name for the column '([^\']*)'$/ do |column|
|
12
|
+
new_instance = @instance.class.new
|
13
|
+
new_instance.send("#{column}_cache=", @instance.send("#{column}_cache"))
|
14
|
+
@instance = new_instance
|
15
|
+
end
|
16
|
+
|
17
|
+
Then /^the url for the column '([^\']*)' should be '([^\']*)'$/ do |column, url|
|
18
|
+
@instance.send("#{column}_url").should == url
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Given /^the file '(.*?)' is stored at '(.*?)'$/ do |file, stored|
|
4
|
+
FileUtils.mkdir_p(File.dirname(file_path(stored)))
|
5
|
+
FileUtils.cp(file_path(file), file_path(stored))
|
6
|
+
end
|
7
|
+
|
8
|
+
When /^I store the file$/ do
|
9
|
+
@uploader.store!
|
10
|
+
end
|
11
|
+
|
12
|
+
When /^I store the file '(.*?)'$/ do |file|
|
13
|
+
@uploader.store!(File.open(file_path(file)))
|
14
|
+
end
|
15
|
+
|
16
|
+
When /^I retrieve the file '(.*?)' from the store$/ do |identifier|
|
17
|
+
@uploader.retrieve_from_store!(identifier)
|
18
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'active_record'
|
4
|
+
require 'carrierwave/mount'
|
5
|
+
require 'carrierwave/orm/activerecord'
|
6
|
+
|
7
|
+
# change this if sqlite is unavailable
|
8
|
+
dbconfig = {
|
9
|
+
:adapter => 'sqlite3',
|
10
|
+
:database => ':memory:'
|
11
|
+
}
|
12
|
+
|
13
|
+
ActiveRecord::Base.establish_connection(dbconfig)
|
14
|
+
ActiveRecord::Migration.verbose = false
|
15
|
+
|
16
|
+
class TestMigration < ActiveRecord::Migration
|
17
|
+
def self.up
|
18
|
+
create_table :users, :force => true do |t|
|
19
|
+
t.column :avatar, :string
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.down
|
24
|
+
drop_table :users
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Before do
|
29
|
+
TestMigration.up
|
30
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
$TESTING=true
|
4
|
+
$:.unshift File.expand_path(File.join('..', '..', 'lib'), File.dirname(__FILE__))
|
5
|
+
|
6
|
+
require File.join(File.dirname(__FILE__), 'activerecord')
|
7
|
+
require File.join(File.dirname(__FILE__), 'datamapper')
|
8
|
+
|
9
|
+
require 'spec'
|
10
|
+
require 'carrierwave'
|
11
|
+
|
12
|
+
alias :running :lambda
|
13
|
+
|
14
|
+
def file_path( *paths )
|
15
|
+
File.expand_path(File.join('..', *paths), File.dirname(__FILE__))
|
16
|
+
end
|
17
|
+
|
18
|
+
CarrierWave.root = file_path('public')
|
19
|
+
|
20
|
+
After do
|
21
|
+
FileUtils.rm_rf(file_path("public"))
|
22
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
Feature: uploader with file storage and versions
|
2
|
+
In order to be awesome
|
3
|
+
As a developer using CarrierWave
|
4
|
+
I want to upload files to the filesystem
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given an uploader class that uses the 'file' storage
|
8
|
+
And that the uploader class has a version named 'thumb'
|
9
|
+
And an instance of that class
|
10
|
+
|
11
|
+
Scenario: store a file
|
12
|
+
When I store the file 'fixtures/bork.txt'
|
13
|
+
Then there should be a file at 'public/uploads/bork.txt'
|
14
|
+
Then there should be a file at 'public/uploads/thumb_bork.txt'
|
15
|
+
And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
16
|
+
And the file at 'public/uploads/thumb_bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
17
|
+
And the uploader should have the url '/uploads/bork.txt'
|
18
|
+
And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt'
|
19
|
+
|
20
|
+
Scenario: cache a file and then store it
|
21
|
+
When I cache the file 'fixtures/bork.txt'
|
22
|
+
Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
|
23
|
+
Then there should be a file called 'thumb_bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
|
24
|
+
And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
|
25
|
+
And there should not be a file at 'public/uploads/bork.txt'
|
26
|
+
And there should not be a file at 'public/uploads/thumb_bork.txt'
|
27
|
+
When I store the file
|
28
|
+
Then there should be a file at 'public/uploads/bork.txt'
|
29
|
+
And there should be a file at 'public/uploads/thumb_bork.txt'
|
30
|
+
And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
31
|
+
And the file at 'public/uploads/thumb_bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
32
|
+
And the uploader should have the url '/uploads/bork.txt'
|
33
|
+
And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt'
|
34
|
+
|
35
|
+
Scenario: retrieving a file from cache then storing
|
36
|
+
Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/bork.txt'
|
37
|
+
Given the file 'fixtures/monkey.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/thumb_bork.txt'
|
38
|
+
When I retrieve the cache name '20090212-2343-8336-0348/bork.txt' from the cache
|
39
|
+
And I store the file
|
40
|
+
Then there should be a file at 'public/uploads/bork.txt'
|
41
|
+
Then there should be a file at 'public/uploads/thumb_bork.txt'
|
42
|
+
And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
43
|
+
And the file at 'public/uploads/thumb_bork.txt' should be identical to the file at 'fixtures/monkey.txt'
|
44
|
+
|
45
|
+
Scenario: retrieving a file from store
|
46
|
+
Given the file 'fixtures/bork.txt' is stored at 'public/uploads/bork.txt'
|
47
|
+
Given the file 'fixtures/monkey.txt' is stored at 'public/uploads/thumb_bork.txt'
|
48
|
+
When I retrieve the file 'bork.txt' from the store
|
49
|
+
Then the uploader should have the url '/uploads/bork.txt'
|
50
|
+
And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt'
|
@@ -0,0 +1,70 @@
|
|
1
|
+
Feature: uploader with nested versions
|
2
|
+
In order to optimize performance for processing
|
3
|
+
As a developer using CarrierWave
|
4
|
+
I want to set nested versions
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given an uploader class that uses the 'file' storage
|
8
|
+
And that the uploader class has a version named 'thumb'
|
9
|
+
And yo dawg, I put a version called 'mini' in your version called 'thumb'
|
10
|
+
And yo dawg, I put a version called 'micro' in your version called 'thumb'
|
11
|
+
And an instance of that class
|
12
|
+
|
13
|
+
Scenario: store a file
|
14
|
+
When I store the file 'fixtures/bork.txt'
|
15
|
+
Then there should be a file at 'public/uploads/bork.txt'
|
16
|
+
Then there should be a file at 'public/uploads/thumb_bork.txt'
|
17
|
+
Then there should be a file at 'public/uploads/thumb_mini_bork.txt'
|
18
|
+
Then there should be a file at 'public/uploads/thumb_micro_bork.txt'
|
19
|
+
And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
20
|
+
And the file at 'public/uploads/thumb_bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
21
|
+
And the file at 'public/uploads/thumb_mini_bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
22
|
+
And the file at 'public/uploads/thumb_micro_bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
23
|
+
And the uploader should have the url '/uploads/bork.txt'
|
24
|
+
And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt'
|
25
|
+
And the uploader's nested version 'mini' nested in 'thumb' should have the url '/uploads/thumb_mini_bork.txt'
|
26
|
+
And the uploader's nested version 'micro' nested in 'thumb' should have the url '/uploads/thumb_micro_bork.txt'
|
27
|
+
|
28
|
+
Scenario: cache a file and then store it
|
29
|
+
When I cache the file 'fixtures/bork.txt'
|
30
|
+
Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
|
31
|
+
Then there should be a file called 'thumb_bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
|
32
|
+
And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
|
33
|
+
And there should not be a file at 'public/uploads/bork.txt'
|
34
|
+
And there should not be a file at 'public/uploads/thumb_bork.txt'
|
35
|
+
When I store the file
|
36
|
+
Then there should be a file at 'public/uploads/bork.txt'
|
37
|
+
And there should be a file at 'public/uploads/thumb_bork.txt'
|
38
|
+
And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
39
|
+
And the file at 'public/uploads/thumb_bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
40
|
+
And the uploader should have the url '/uploads/bork.txt'
|
41
|
+
And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt'
|
42
|
+
And the uploader's nested version 'mini' nested in 'thumb' should have the url '/uploads/thumb_mini_bork.txt'
|
43
|
+
And the uploader's nested version 'micro' nested in 'thumb' should have the url '/uploads/thumb_micro_bork.txt'
|
44
|
+
|
45
|
+
Scenario: retrieving a file from cache then storing
|
46
|
+
Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/bork.txt'
|
47
|
+
Given the file 'fixtures/monkey.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/thumb_bork.txt'
|
48
|
+
Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/thumb_mini_bork.txt'
|
49
|
+
Given the file 'fixtures/monkey.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/thumb_micro_bork.txt'
|
50
|
+
When I retrieve the cache name '20090212-2343-8336-0348/bork.txt' from the cache
|
51
|
+
And I store the file
|
52
|
+
Then there should be a file at 'public/uploads/bork.txt'
|
53
|
+
Then there should be a file at 'public/uploads/thumb_bork.txt'
|
54
|
+
Then there should be a file at 'public/uploads/thumb_mini_bork.txt'
|
55
|
+
Then there should be a file at 'public/uploads/thumb_micro_bork.txt'
|
56
|
+
And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
57
|
+
And the file at 'public/uploads/thumb_bork.txt' should be identical to the file at 'fixtures/monkey.txt'
|
58
|
+
And the file at 'public/uploads/thumb_mini_bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
59
|
+
And the file at 'public/uploads/thumb_micro_bork.txt' should be identical to the file at 'fixtures/monkey.txt'
|
60
|
+
|
61
|
+
Scenario: retrieving a file from store
|
62
|
+
Given the file 'fixtures/bork.txt' is stored at 'public/uploads/bork.txt'
|
63
|
+
Given the file 'fixtures/monkey.txt' is stored at 'public/uploads/thumb_bork.txt'
|
64
|
+
Given the file 'fixtures/monkey.txt' is stored at 'public/uploads/thumb_mini_bork.txt'
|
65
|
+
Given the file 'fixtures/monkey.txt' is stored at 'public/uploads/thumb_micro_bork.txt'
|
66
|
+
When I retrieve the file 'bork.txt' from the store
|
67
|
+
Then the uploader should have the url '/uploads/bork.txt'
|
68
|
+
And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt'
|
69
|
+
And the uploader's nested version 'mini' nested in 'thumb' should have the url '/uploads/thumb_mini_bork.txt'
|
70
|
+
And the uploader's nested version 'micro' nested in 'thumb' should have the url '/uploads/thumb_micro_bork.txt'
|
@@ -0,0 +1,51 @@
|
|
1
|
+
Feature: uploader with file storage and overriden filename
|
2
|
+
In order to customize the filaname of uploaded files
|
3
|
+
As a developer using CarrierWave
|
4
|
+
I want to upload files to the filesystem with an overriden filename and different verions
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given an uploader class that uses the 'file' storage
|
8
|
+
And that the uploader class has a version named 'thumb'
|
9
|
+
And that the uploader has the filename overridden to 'grark.png'
|
10
|
+
And an instance of that class
|
11
|
+
|
12
|
+
Scenario: store a file
|
13
|
+
When I store the file 'fixtures/bork.txt'
|
14
|
+
Then there should be a file at 'public/uploads/grark.png'
|
15
|
+
Then there should be a file at 'public/uploads/thumb_grark.png'
|
16
|
+
And the file at 'public/uploads/grark.png' should be identical to the file at 'fixtures/bork.txt'
|
17
|
+
And the file at 'public/uploads/thumb_grark.png' should be identical to the file at 'fixtures/bork.txt'
|
18
|
+
And the uploader should have the url '/uploads/grark.png'
|
19
|
+
And the uploader's version 'thumb' should have the url '/uploads/thumb_grark.png'
|
20
|
+
|
21
|
+
Scenario: cache a file and then store it
|
22
|
+
When I cache the file 'fixtures/bork.txt'
|
23
|
+
Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
|
24
|
+
Then there should be a file called 'thumb_bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
|
25
|
+
And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
|
26
|
+
And there should not be a file at 'public/uploads/grark.png'
|
27
|
+
And there should not be a file at 'public/uploads/thumb_grark.png'
|
28
|
+
When I store the file
|
29
|
+
Then there should be a file at 'public/uploads/grark.png'
|
30
|
+
And there should be a file at 'public/uploads/thumb_grark.png'
|
31
|
+
And the file at 'public/uploads/grark.png' should be identical to the file at 'fixtures/bork.txt'
|
32
|
+
And the file at 'public/uploads/thumb_grark.png' should be identical to the file at 'fixtures/bork.txt'
|
33
|
+
And the uploader should have the url '/uploads/grark.png'
|
34
|
+
And the uploader's version 'thumb' should have the url '/uploads/thumb_grark.png'
|
35
|
+
|
36
|
+
Scenario: retrieving a file from cache then storing
|
37
|
+
Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/bork.txt'
|
38
|
+
Given the file 'fixtures/monkey.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/thumb_bork.txt'
|
39
|
+
When I retrieve the cache name '20090212-2343-8336-0348/bork.txt' from the cache
|
40
|
+
And I store the file
|
41
|
+
Then there should be a file at 'public/uploads/grark.png'
|
42
|
+
Then there should be a file at 'public/uploads/thumb_grark.png'
|
43
|
+
And the file at 'public/uploads/grark.png' should be identical to the file at 'fixtures/bork.txt'
|
44
|
+
And the file at 'public/uploads/thumb_grark.png' should be identical to the file at 'fixtures/monkey.txt'
|
45
|
+
|
46
|
+
Scenario: retrieving a file from store
|
47
|
+
Given the file 'fixtures/bork.txt' is stored at 'public/uploads/bork.txt'
|
48
|
+
Given the file 'fixtures/monkey.txt' is stored at 'public/uploads/thumb_bork.txt'
|
49
|
+
When I retrieve the file 'bork.txt' from the store
|
50
|
+
Then the uploader should have the url '/uploads/bork.txt'
|
51
|
+
And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt'
|