durran-carrierwave 0.3.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/Generators +4 -0
  2. data/History.txt +66 -0
  3. data/LICENSE +8 -0
  4. data/Manifest.txt +89 -0
  5. data/README.rdoc +342 -0
  6. data/Rakefile +30 -0
  7. data/carrierwave.gemspec +57 -0
  8. data/cucumber.yml +2 -0
  9. data/features/caching.feature +28 -0
  10. data/features/file_storage.feature +37 -0
  11. data/features/file_storage_overridden_filename.feature +38 -0
  12. data/features/file_storage_overridden_store_dir.feature +38 -0
  13. data/features/file_storage_reversing_processor.feature +43 -0
  14. data/features/fixtures/bork.txt +1 -0
  15. data/features/fixtures/monkey.txt +1 -0
  16. data/features/mount_activerecord.feature +46 -0
  17. data/features/mount_datamapper.feature +46 -0
  18. data/features/step_definitions/activerecord_steps.rb +22 -0
  19. data/features/step_definitions/caching_steps.rb +14 -0
  20. data/features/step_definitions/datamapper_steps.rb +29 -0
  21. data/features/step_definitions/file_steps.rb +42 -0
  22. data/features/step_definitions/general_steps.rb +80 -0
  23. data/features/step_definitions/mount_steps.rb +19 -0
  24. data/features/step_definitions/store_steps.rb +18 -0
  25. data/features/support/activerecord.rb +30 -0
  26. data/features/support/datamapper.rb +7 -0
  27. data/features/support/env.rb +35 -0
  28. data/features/versions_basics.feature +50 -0
  29. data/features/versions_nested_versions.feature +70 -0
  30. data/features/versions_overridden_filename.feature +51 -0
  31. data/features/versions_overriden_store_dir.feature +41 -0
  32. data/lib/carrierwave.rb +145 -0
  33. data/lib/carrierwave/compatibility/paperclip.rb +95 -0
  34. data/lib/carrierwave/core_ext/blank.rb +46 -0
  35. data/lib/carrierwave/core_ext/inheritable_attributes.rb +104 -0
  36. data/lib/carrierwave/core_ext/module_setup.rb +51 -0
  37. data/lib/carrierwave/mount.rb +332 -0
  38. data/lib/carrierwave/orm/activerecord.rb +73 -0
  39. data/lib/carrierwave/orm/datamapper.rb +27 -0
  40. data/lib/carrierwave/orm/mongomapper.rb +27 -0
  41. data/lib/carrierwave/orm/sequel.rb +57 -0
  42. data/lib/carrierwave/processing/image_science.rb +72 -0
  43. data/lib/carrierwave/processing/rmagick.rb +286 -0
  44. data/lib/carrierwave/sanitized_file.rb +272 -0
  45. data/lib/carrierwave/storage/abstract.rb +32 -0
  46. data/lib/carrierwave/storage/file.rb +50 -0
  47. data/lib/carrierwave/storage/s3.rb +215 -0
  48. data/lib/carrierwave/test/matchers.rb +114 -0
  49. data/lib/carrierwave/uploader.rb +43 -0
  50. data/lib/carrierwave/uploader/cache.rb +116 -0
  51. data/lib/carrierwave/uploader/callbacks.rb +42 -0
  52. data/lib/carrierwave/uploader/default_path.rb +23 -0
  53. data/lib/carrierwave/uploader/extension_whitelist.rb +37 -0
  54. data/lib/carrierwave/uploader/mountable.rb +39 -0
  55. data/lib/carrierwave/uploader/paths.rb +27 -0
  56. data/lib/carrierwave/uploader/processing.rb +81 -0
  57. data/lib/carrierwave/uploader/proxy.rb +62 -0
  58. data/lib/carrierwave/uploader/remove.rb +23 -0
  59. data/lib/carrierwave/uploader/store.rb +156 -0
  60. data/lib/carrierwave/uploader/url.rb +24 -0
  61. data/lib/carrierwave/uploader/versions.rb +147 -0
  62. data/lib/generators/uploader_generator.rb +22 -0
  63. data/rails_generators/uploader/USAGE +2 -0
  64. data/rails_generators/uploader/templates/uploader.rb +47 -0
  65. data/rails_generators/uploader/uploader_generator.rb +21 -0
  66. data/script/console +10 -0
  67. data/script/destroy +14 -0
  68. data/script/generate +14 -0
  69. data/spec/compatibility/paperclip_spec.rb +43 -0
  70. data/spec/fixtures/bork.txt +1 -0
  71. data/spec/fixtures/test.jpeg +1 -0
  72. data/spec/fixtures/test.jpg +1 -0
  73. data/spec/mount_spec.rb +517 -0
  74. data/spec/orm/activerecord_spec.rb +271 -0
  75. data/spec/orm/datamapper_spec.rb +161 -0
  76. data/spec/orm/mongomapper_spec.rb +184 -0
  77. data/spec/orm/sequel_spec.rb +192 -0
  78. data/spec/sanitized_file_spec.rb +612 -0
  79. data/spec/spec_helper.rb +99 -0
  80. data/spec/uploader/cache_spec.rb +196 -0
  81. data/spec/uploader/default_path_spec.rb +68 -0
  82. data/spec/uploader/extension_whitelist_spec.rb +44 -0
  83. data/spec/uploader/mountable_spec.rb +33 -0
  84. data/spec/uploader/paths_spec.rb +22 -0
  85. data/spec/uploader/processing_spec.rb +62 -0
  86. data/spec/uploader/proxy_spec.rb +54 -0
  87. data/spec/uploader/remove_spec.rb +70 -0
  88. data/spec/uploader/store_spec.rb +274 -0
  89. data/spec/uploader/url_spec.rb +87 -0
  90. data/spec/uploader/versions_spec.rb +306 -0
  91. metadata +228 -0
@@ -0,0 +1,42 @@
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
+ # REVERSING
39
+
40
+ Then /^the file at '(.*?)' should be the reverse of the file at '(.*?)'$/ do |one, two|
41
+ File.read(file_path(one)).should == File.read(file_path(two)).reverse
42
+ end
@@ -0,0 +1,80 @@
1
+ # encoding: utf-8
2
+
3
+ Given /^an uploader class that uses the 'file' storage$/ do
4
+ @klass = Class.new(CarrierWave::Uploader::Base)
5
+ end
6
+
7
+ Given /^an instance of that class$/ do
8
+ @uploader = @klass.new
9
+ end
10
+
11
+ Given /^that the uploader reverses the filename$/ do
12
+ @klass.class_eval do
13
+ def filename
14
+ super.reverse unless super.blank?
15
+ end
16
+ end
17
+ end
18
+
19
+ Given /^that the uploader has the filename overridden to '(.*?)'$/ do |filename|
20
+ @klass.class_eval do
21
+ define_method(:filename) do
22
+ filename
23
+ end
24
+ end
25
+ end
26
+
27
+ Given /^that the uploader has the store_dir overridden to '(.*?)'$/ do |store_dir|
28
+ @klass.class_eval do
29
+ define_method(:store_dir) do
30
+ file_path(store_dir)
31
+ end
32
+ end
33
+ end
34
+
35
+ Given /^that the version '(.*?)' has the store_dir overridden to '(.*?)'$/ do |version, store_dir|
36
+ @klass.versions[version.to_sym].class_eval do
37
+ define_method(:store_dir) do
38
+ file_path(store_dir)
39
+ end
40
+ end
41
+ end
42
+
43
+ Given /^that the uploader class has a version named '(.*?)'$/ do |name|
44
+ @klass.version(name)
45
+ end
46
+
47
+ Given /^yo dawg, I put a version called '(.*?)' in your version called '(.*?)'$/ do |v2, v1|
48
+ @klass.version(v1) do
49
+ version(v2)
50
+ end
51
+ end
52
+
53
+ Given /^the class has a method called 'reverse' that reverses the contents of a file$/ do
54
+ @klass.class_eval do
55
+ def reverse
56
+ text = File.read(current_path)
57
+ File.open(current_path, 'w') { |f| f.write(text.reverse) }
58
+ end
59
+ end
60
+ end
61
+
62
+ Given /^the class will process '([a-zA-Z0-9\_\?!]*)'$/ do |name|
63
+ @klass.process name.to_sym
64
+ end
65
+
66
+ Then /^the uploader should have '(.*?)' as its current path$/ do |path|
67
+ @uploader.current_path.should == file_path(path)
68
+ end
69
+
70
+ Then /^the uploader should have the url '(.*?)'$/ do |url|
71
+ @uploader.url.should == url
72
+ end
73
+
74
+ Then /^the uploader's version '(.*?)' should have the url '(.*?)'$/ do |version, url|
75
+ @uploader.versions[version.to_sym].url.should == url
76
+ end
77
+
78
+ Then /^the uploader's nested version '(.*?)' nested in '(.*?)' should have the url '(.*?)'$/ do |v2, v1, url|
79
+ @uploader.versions[v1.to_sym].versions[v2.to_sym].url.should == url
80
+ 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 'activerecord'
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,7 @@
1
+ # encoding: utf-8
2
+
3
+ require 'dm-core'
4
+ require 'carrierwave/mount'
5
+ require 'carrierwave/orm/datamapper'
6
+
7
+ DataMapper.setup(:default, 'sqlite3::memory:')
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+
3
+ $TESTING=true
4
+ $:.push File.join(File.dirname(__FILE__), '..', 'lib')
5
+
6
+ require 'rubygems'
7
+ require File.join(File.dirname(__FILE__), 'activerecord')
8
+ require File.join(File.dirname(__FILE__), 'datamapper')
9
+
10
+ if ENV["AS"]
11
+ puts "--> using ActiveSupport"
12
+ require 'activesupport'
13
+ elsif ENV["EXTLIB"]
14
+ puts "--> using Extlib"
15
+ require 'extlib'
16
+ end
17
+
18
+ require 'tempfile'
19
+ #require 'ruby-debug'
20
+ require 'spec'
21
+
22
+ require 'carrierwave'
23
+
24
+ alias :running :lambda
25
+
26
+ def file_path( *paths )
27
+ File.expand_path(File.join(File.dirname(__FILE__), '..', *paths))
28
+ end
29
+
30
+ CarrierWave.config[:public] = file_path('public')
31
+ CarrierWave.config[:root] = file_path
32
+
33
+ After do
34
+ FileUtils.rm_rf(file_path("public"))
35
+ 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'
@@ -0,0 +1,41 @@
1
+ Feature: uploader with file storage and versions with overridden store dir
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 that the version 'thumb' has the store_dir overridden to 'public/monkey/llama'
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/bork.txt'
15
+ Then there should be a file at 'public/monkey/llama/thumb_bork.txt'
16
+ And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
17
+ And the file at 'public/monkey/llama/thumb_bork.txt' should be identical to the file at 'fixtures/bork.txt'
18
+
19
+ Scenario: cache a file and then store it
20
+ When I cache the file 'fixtures/bork.txt'
21
+ Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
22
+ Then there should be a file called 'thumb_bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
23
+ And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
24
+ And the file called 'thumb_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/monkey/llama/thumb_bork.txt'
27
+ When I store the file
28
+ Then there should be a file at 'public/uploads/bork.txt'
29
+ Then there should be a file at 'public/monkey/llama/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/monkey/llama/thumb_bork.txt' should be identical to the file at 'fixtures/bork.txt'
32
+
33
+ Scenario: retrieving a file from cache then storing
34
+ Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/bork.txt'
35
+ Given the file 'fixtures/monkey.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/thumb_bork.txt'
36
+ When I retrieve the cache name '20090212-2343-8336-0348/bork.txt' from the cache
37
+ And I store the file
38
+ Then there should be a file at 'public/uploads/bork.txt'
39
+ Then there should be a file at 'public/monkey/llama/thumb_bork.txt'
40
+ And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
41
+ And the file at 'public/monkey/llama/thumb_bork.txt' should be identical to the file at 'fixtures/monkey.txt'