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,30 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/carrierwave'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ Hoe.plugin :cucumberfeatures
10
+
11
+ $hoe = Hoe.spec 'carrierwave' do
12
+ self.developer 'Jonas Nicklas', 'jonas.nicklas@gmail.com'
13
+ self.rubyforge_name = self.name
14
+ self.readme_file = 'README.rdoc'
15
+ self.version = CarrierWave::VERSION
16
+ self.extra_dev_deps << ['rspec', '>=1.2.8']
17
+ self.extra_dev_deps << ['cucumber', '>=0.3.96']
18
+ self.extra_dev_deps << ['activerecord', '>=2.3.3']
19
+ self.extra_dev_deps << ['dm-core', '>=0.9.11']
20
+ self.extra_dev_deps << ['sequel', '>=3.2.0']
21
+ self.extra_dev_deps << ['rmagick', '>=2.10.0']
22
+ self.extra_dev_deps << ['mongomapper', '>=0.3.3']
23
+ self.extra_rdoc_files << 'README.rdoc'
24
+ self.extra_rdoc_files << 'LICENSE'
25
+ end
26
+
27
+ require 'newgem/tasks'
28
+ Dir['tasks/**/*.rake'].each { |t| load t }
29
+
30
+ task :default => [:spec, :features]
@@ -0,0 +1,57 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{carrierwave}
5
+ s.version = "0.3.2.3"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Jonas Nicklas"]
9
+ s.date = %q{2009-08-28}
10
+ s.description = %q{* RDoc Documentation {available at Rubyforge}[http://carrierwave.rubyforge.org/].
11
+ * Source code {hosted at GitHub}[http://github.com/jnicklas/carrierwave]
12
+ * Please {report any issues}[http://github.com/jnicklas/carrierwave/issues] on GitHub
13
+ * Please direct any questions at the {mailing list}[http://groups.google.com/group/carrierwave]}
14
+ s.email = ["jonas.nicklas@gmail.com"]
15
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt", "features/fixtures/bork.txt", "features/fixtures/monkey.txt", "README.rdoc", "LICENSE"]
16
+ s.files = ["Generators", "History.txt", "Manifest.txt", "README.rdoc", "Rakefile", "carrierwave.gemspec", "cucumber.yml", "features/caching.feature", "features/file_storage.feature", "features/file_storage_overridden_filename.feature", "features/file_storage_overridden_store_dir.feature", "features/file_storage_reversing_processor.feature", "features/fixtures/bork.txt", "features/fixtures/monkey.txt", "features/mount_activerecord.feature", "features/mount_datamapper.feature", "features/step_definitions/activerecord_steps.rb", "features/step_definitions/caching_steps.rb", "features/step_definitions/datamapper_steps.rb", "features/step_definitions/file_steps.rb", "features/step_definitions/general_steps.rb", "features/step_definitions/mount_steps.rb", "features/step_definitions/store_steps.rb", "features/support/activerecord.rb", "features/support/datamapper.rb", "features/support/env.rb", "features/versions_basics.feature", "features/versions_nested_versions.feature", "features/versions_overridden_filename.feature", "features/versions_overriden_store_dir.feature", "lib/carrierwave.rb", "lib/carrierwave/compatibility/paperclip.rb", "lib/carrierwave/core_ext/blank.rb", "lib/carrierwave/core_ext/inheritable_attributes.rb", "lib/carrierwave/core_ext/module_setup.rb", "lib/carrierwave/mount.rb", "lib/carrierwave/orm/activerecord.rb", "lib/carrierwave/orm/datamapper.rb", "lib/carrierwave/orm/mongomapper.rb", "lib/carrierwave/orm/sequel.rb", "lib/carrierwave/processing/image_science.rb", "lib/carrierwave/processing/rmagick.rb", "lib/carrierwave/sanitized_file.rb", "lib/carrierwave/storage/abstract.rb", "lib/carrierwave/storage/file.rb", "lib/carrierwave/storage/s3.rb", "lib/carrierwave/test/matchers.rb", "lib/carrierwave/uploader.rb", "lib/carrierwave/uploader/cache.rb", "lib/carrierwave/uploader/callbacks.rb", "lib/carrierwave/uploader/default_path.rb", "lib/carrierwave/uploader/extension_whitelist.rb", "lib/carrierwave/uploader/mountable.rb", "lib/carrierwave/uploader/paths.rb", "lib/carrierwave/uploader/processing.rb", "lib/carrierwave/uploader/proxy.rb", "lib/carrierwave/uploader/remove.rb", "lib/carrierwave/uploader/store.rb", "lib/carrierwave/uploader/url.rb", "lib/carrierwave/uploader/versions.rb", "lib/generators/uploader_generator.rb", "rails_generators/uploader/USAGE", "rails_generators/uploader/templates/uploader.rb", "rails_generators/uploader/uploader_generator.rb", "script/console", "script/destroy", "script/generate", "spec/compatibility/paperclip_spec.rb", "spec/fixtures/bork.txt", "spec/fixtures/test.jpeg", "spec/fixtures/test.jpg", "spec/mount_spec.rb", "spec/orm/activerecord_spec.rb", "spec/orm/datamapper_spec.rb", "spec/orm/mongomapper_spec.rb", "spec/orm/sequel_spec.rb", "spec/sanitized_file_spec.rb", "spec/spec_helper.rb", "spec/uploader/cache_spec.rb", "spec/uploader/default_path_spec.rb", "spec/uploader/extension_whitelist_spec.rb", "spec/uploader/mountable_spec.rb", "spec/uploader/paths_spec.rb", "spec/uploader/processing_spec.rb", "spec/uploader/proxy_spec.rb", "spec/uploader/remove_spec.rb", "spec/uploader/store_spec.rb", "spec/uploader/url_spec.rb", "spec/uploader/versions_spec.rb", "LICENSE"]
17
+ s.homepage = %q{http://carrierwave.rubyforge.org}
18
+ s.rdoc_options = ["--main", "README.rdoc"]
19
+ s.require_paths = ["lib"]
20
+ s.rubyforge_project = %q{carrierwave}
21
+ s.rubygems_version = %q{1.3.5}
22
+ s.summary = %q{* RDoc Documentation {available at Rubyforge}[http://carrierwave.rubyforge.org/]}
23
+
24
+ if s.respond_to? :specification_version then
25
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
26
+ s.specification_version = 3
27
+
28
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
29
+ s.add_development_dependency(%q<rspec>, [">= 1.2.8"])
30
+ s.add_development_dependency(%q<cucumber>, [">= 0.3.96"])
31
+ s.add_development_dependency(%q<activerecord>, [">= 2.3.3"])
32
+ s.add_development_dependency(%q<dm-core>, [">= 0.9.11"])
33
+ s.add_development_dependency(%q<sequel>, [">= 3.2.0"])
34
+ s.add_development_dependency(%q<rmagick>, [">= 2.10.0"])
35
+ s.add_development_dependency(%q<mongomapper>, [">= 0.3.3"])
36
+ s.add_development_dependency(%q<hoe>, [">= 2.3.2"])
37
+ else
38
+ s.add_dependency(%q<rspec>, [">= 1.2.8"])
39
+ s.add_dependency(%q<cucumber>, [">= 0.3.96"])
40
+ s.add_dependency(%q<activerecord>, [">= 2.3.3"])
41
+ s.add_dependency(%q<dm-core>, [">= 0.9.11"])
42
+ s.add_dependency(%q<sequel>, [">= 3.2.0"])
43
+ s.add_dependency(%q<rmagick>, [">= 2.10.0"])
44
+ s.add_dependency(%q<mongomapper>, [">= 0.3.3"])
45
+ s.add_dependency(%q<hoe>, [">= 2.3.2"])
46
+ end
47
+ else
48
+ s.add_dependency(%q<rspec>, [">= 1.2.8"])
49
+ s.add_dependency(%q<cucumber>, [">= 0.3.96"])
50
+ s.add_dependency(%q<activerecord>, [">= 2.3.3"])
51
+ s.add_dependency(%q<dm-core>, [">= 0.9.11"])
52
+ s.add_dependency(%q<sequel>, [">= 3.2.0"])
53
+ s.add_dependency(%q<rmagick>, [">= 2.10.0"])
54
+ s.add_dependency(%q<mongomapper>, [">= 0.3.3"])
55
+ s.add_dependency(%q<hoe>, [">= 2.3.2"])
56
+ end
57
+ end
@@ -0,0 +1,2 @@
1
+ default: --format pretty --no-source
2
+ html: --format html --out features.html
@@ -0,0 +1,28 @@
1
+ Feature: uploader with file storage
2
+ In order to be able to temporarily store files to disk
3
+ As a developer using CarrierWave
4
+ I want to cache files
5
+
6
+ Scenario: cache a file
7
+ Given an uploader class that uses the 'file' storage
8
+ And an instance of that class
9
+ When I cache the file 'fixtures/bork.txt'
10
+ Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
11
+ And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
12
+
13
+ Scenario: cache two files in succession
14
+ Given an uploader class that uses the 'file' storage
15
+ And an instance of that class
16
+ When I cache the file 'fixtures/bork.txt'
17
+ Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
18
+ And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
19
+ When I cache the file 'fixtures/monkey.txt'
20
+ Then there should be a file called 'monkey.txt' somewhere in a subdirectory of 'public/uploads/tmp'
21
+ And the file called 'monkey.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/monkey.txt'
22
+
23
+ Scenario: retrieving a file from cache
24
+ Given an uploader class that uses the 'file' storage
25
+ And an instance of that class
26
+ And the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/bork.txt'
27
+ When I retrieve the cache name '20090212-2343-8336-0348/bork.txt' from the cache
28
+ Then the uploader should have 'public/uploads/tmp/20090212-2343-8336-0348/bork.txt' as its current path
@@ -0,0 +1,37 @@
1
+ Feature: uploader with file storage
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 an instance of that class
9
+
10
+ Scenario: store a file
11
+ When I store the file 'fixtures/bork.txt'
12
+ Then there should be a file at 'public/uploads/bork.txt'
13
+ And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
14
+
15
+ Scenario: store two files in succession
16
+ When I store the file 'fixtures/bork.txt'
17
+ Then there should be a file at 'public/uploads/bork.txt'
18
+ And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
19
+ When I store the file 'fixtures/monkey.txt'
20
+ Then there should be a file at 'public/uploads/monkey.txt'
21
+ And the file at 'public/uploads/monkey.txt' should be identical to the file at 'fixtures/monkey.txt'
22
+
23
+ Scenario: cache a file and then store it
24
+ When I cache the file 'fixtures/bork.txt'
25
+ Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
26
+ And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
27
+ And there should not be a file at 'public/uploads/bork.txt'
28
+ When I store the file
29
+ Then there should be a file at 'public/uploads/bork.txt'
30
+ And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
31
+
32
+ Scenario: retrieving a file from cache then storing
33
+ Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/bork.txt'
34
+ When I retrieve the cache name '20090212-2343-8336-0348/bork.txt' from the cache
35
+ And I store the file
36
+ Then there should be a file at 'public/uploads/bork.txt'
37
+ And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
@@ -0,0 +1,38 @@
1
+ Feature: uploader with file storage and overriden filename
2
+ In order to be awesome
3
+ As a developer using CarrierWave
4
+ I want to upload files to the filesystem with an overriden filename
5
+
6
+ Background:
7
+ Given an uploader class that uses the 'file' storage
8
+ And that the uploader reverses the filename
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/txt.krob'
14
+ And the file at 'public/uploads/txt.krob' should be identical to the file at 'fixtures/bork.txt'
15
+
16
+ Scenario: store two files in succession
17
+ When I store the file 'fixtures/bork.txt'
18
+ Then there should be a file at 'public/uploads/txt.krob'
19
+ And the file at 'public/uploads/txt.krob' should be identical to the file at 'fixtures/bork.txt'
20
+ When I store the file 'fixtures/monkey.txt'
21
+ Then there should be a file at 'public/uploads/txt.yeknom'
22
+ And the file at 'public/uploads/txt.yeknom' should be identical to the file at 'fixtures/monkey.txt'
23
+
24
+ Scenario: cache a file and then store it
25
+ When I cache the file 'fixtures/bork.txt'
26
+ Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
27
+ And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
28
+ And there should not be a file at 'public/uploads/txt.krob'
29
+ When I store the file
30
+ Then there should be a file at 'public/uploads/txt.krob'
31
+ And the file at 'public/uploads/txt.krob' 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
+ When I retrieve the cache name '20090212-2343-8336-0348/bork.txt' from the cache
36
+ And I store the file
37
+ Then there should be a file at 'public/uploads/txt.krob'
38
+ And the file at 'public/uploads/txt.krob' should be identical to the file at 'fixtures/bork.txt'
@@ -0,0 +1,38 @@
1
+ Feature: uploader with file storage and 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 has the store_dir overridden to 'public/monkey/llama'
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/monkey/llama/bork.txt'
14
+ And the file at 'public/monkey/llama/bork.txt' should be identical to the file at 'fixtures/bork.txt'
15
+
16
+ Scenario: store two files in succession
17
+ When I store the file 'fixtures/bork.txt'
18
+ Then there should be a file at 'public/monkey/llama/bork.txt'
19
+ And the file at 'public/monkey/llama/bork.txt' should be identical to the file at 'fixtures/bork.txt'
20
+ When I store the file 'fixtures/monkey.txt'
21
+ Then there should be a file at 'public/monkey/llama/monkey.txt'
22
+ And the file at 'public/monkey/llama/monkey.txt' should be identical to the file at 'fixtures/monkey.txt'
23
+
24
+ Scenario: cache a file and then store it
25
+ When I cache the file 'fixtures/bork.txt'
26
+ Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
27
+ And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
28
+ And there should not be a file at 'public/monkey/llama/bork.txt'
29
+ When I store the file
30
+ Then there should be a file at 'public/monkey/llama/bork.txt'
31
+ And the file at 'public/monkey/llama/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
+ When I retrieve the cache name '20090212-2343-8336-0348/bork.txt' from the cache
36
+ And I store the file
37
+ Then there should be a file at 'public/monkey/llama/bork.txt'
38
+ And the file at 'public/monkey/llama/bork.txt' should be identical to the file at 'fixtures/bork.txt'
@@ -0,0 +1,43 @@
1
+ Feature: uploader with file storage and a processor that reverses the file
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 an instance of that class
9
+ And the class has a method called 'reverse' that reverses the contents of a file
10
+ And the class will process 'reverse'
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
+ And the file at 'public/uploads/bork.txt' should not be identical to the file at 'fixtures/bork.txt'
16
+ And the file at 'public/uploads/bork.txt' should be the reverse of the file at 'fixtures/bork.txt'
17
+
18
+ Scenario: store two files in succession
19
+ When I store the file 'fixtures/bork.txt'
20
+ Then there should be a file at 'public/uploads/bork.txt'
21
+ And the file at 'public/uploads/bork.txt' should not be identical to the file at 'fixtures/bork.txt'
22
+ And the file at 'public/uploads/bork.txt' should be the reverse of the file at 'fixtures/bork.txt'
23
+ When I store the file 'fixtures/monkey.txt'
24
+ Then there should be a file at 'public/uploads/monkey.txt'
25
+ And the file at 'public/uploads/monkey.txt' should not be identical to the file at 'fixtures/monkey.txt'
26
+ And the file at 'public/uploads/monkey.txt' should be the reverse of the file at 'fixtures/monkey.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
+ And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should not be identical to the file at 'fixtures/bork.txt'
32
+ And there should not be a file at 'public/uploads/bork.txt'
33
+ When I store the file
34
+ Then there should be a file at 'public/uploads/bork.txt'
35
+ And the file at 'public/uploads/bork.txt' should not be identical to the file at 'fixtures/bork.txt'
36
+ And the file at 'public/uploads/bork.txt' should be the reverse of the file at 'fixtures/bork.txt'
37
+
38
+ Scenario: retrieving a file from cache then storing
39
+ Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/bork.txt'
40
+ When I retrieve the cache name '20090212-2343-8336-0348/bork.txt' from the cache
41
+ And I store the file
42
+ Then there should be a file at 'public/uploads/bork.txt'
43
+ And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
@@ -0,0 +1 @@
1
+ this is a file
@@ -0,0 +1 @@
1
+ this is another file
@@ -0,0 +1,46 @@
1
+ Feature: Mount an Uploader on ActiveRecord class
2
+ In order to easily attach files to a form
3
+ As a web developer using CarrierWave
4
+ I want to mount an uploader on an ActiveRecord class
5
+
6
+ Background:
7
+ Given an uploader class that uses the 'file' storage
8
+ And an activerecord class that uses the 'users' table
9
+ And the uploader class is mounted on the 'avatar' column
10
+ And an instance of the activerecord class
11
+
12
+ Scenario: assign a file
13
+ When I assign the file 'fixtures/bork.txt' to the 'avatar' column
14
+ Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
15
+ And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
16
+
17
+ Scenario: assign a file and save the record
18
+ When I assign the file 'fixtures/bork.txt' to the 'avatar' column
19
+ And I save the active record
20
+ Then there should be a file at 'public/uploads/bork.txt'
21
+ And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
22
+ And the url for the column 'avatar' should be '/uploads/bork.txt'
23
+
24
+ Scenario: assign a file and retrieve it from cache
25
+ When I assign the file 'fixtures/bork.txt' to the 'avatar' column
26
+ And I retrieve the file later from the cache name for the column 'avatar'
27
+ And I save the active record
28
+ Then there should be a file at 'public/uploads/bork.txt'
29
+ And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
30
+ And the url for the column 'avatar' should be '/uploads/bork.txt'
31
+
32
+ Scenario: store a file and retrieve it later
33
+ When I assign the file 'fixtures/bork.txt' to the 'avatar' column
34
+ And I retrieve the file later from the cache name for the column 'avatar'
35
+ And I save the active record
36
+ Then there should be a file at 'public/uploads/bork.txt'
37
+ When I reload the active record
38
+ Then the url for the column 'avatar' should be '/uploads/bork.txt'
39
+
40
+ Scenario: store a file and delete the record
41
+ When I assign the file 'fixtures/bork.txt' to the 'avatar' column
42
+ And I retrieve the file later from the cache name for the column 'avatar'
43
+ And I save the active record
44
+ Then there should be a file at 'public/uploads/bork.txt'
45
+ When I delete the active record
46
+ Then there should not be a file at 'public/uploads/bork.txt'
@@ -0,0 +1,46 @@
1
+ Feature: Mount an Uploader on ActiveRecord class
2
+ In order to easily attach files to a form
3
+ As a web developer using CarrierWave
4
+ I want to mount an uploader on an ActiveRecord class
5
+
6
+ Background:
7
+ Given an uploader class that uses the 'file' storage
8
+ And a datamapper class that has a 'avatar' column
9
+ And the uploader class is mounted on the 'avatar' column
10
+ And an instance of the datamapper class
11
+
12
+ Scenario: assign a file
13
+ When I assign the file 'fixtures/bork.txt' to the 'avatar' column
14
+ Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
15
+ And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
16
+
17
+ Scenario: assign a file and save the record
18
+ When I assign the file 'fixtures/bork.txt' to the 'avatar' column
19
+ And I save the datamapper record
20
+ Then there should be a file at 'public/uploads/bork.txt'
21
+ And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
22
+ And the url for the column 'avatar' should be '/uploads/bork.txt'
23
+
24
+ Scenario: assign a file and retrieve it from cache
25
+ When I assign the file 'fixtures/bork.txt' to the 'avatar' column
26
+ And I retrieve the file later from the cache name for the column 'avatar'
27
+ And I save the datamapper record
28
+ Then there should be a file at 'public/uploads/bork.txt'
29
+ And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
30
+ And the url for the column 'avatar' should be '/uploads/bork.txt'
31
+
32
+ # Scenario: store a file and retrieve it later
33
+ # When I assign the file 'fixtures/bork.txt' to the 'avatar' column
34
+ # And I retrieve the file later from the cache name for the column 'avatar'
35
+ # And I save the datamapper record
36
+ # Then there should be a file at 'public/uploads/bork.txt'
37
+ # When I reload the datamapper record
38
+ # Then the url for the column 'avatar' should be '/uploads/bork.txt'
39
+ #
40
+ # Scenario: store a file and delete the record
41
+ # When I assign the file 'fixtures/bork.txt' to the 'avatar' column
42
+ # And I retrieve the file later from the cache name for the column 'avatar'
43
+ # And I save the datamapper record
44
+ # Then there should be a file at 'public/uploads/bork.txt'
45
+ # When I delete the datamapper record
46
+ # Then there should not be a file at 'public/uploads/bork.txt'
@@ -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