paperclip 4.1.1 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of paperclip might be problematic. Click here for more details.

Files changed (152) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -6
  3. data/.travis.yml +4 -13
  4. data/Appraisals +0 -10
  5. data/CONTRIBUTING.md +10 -5
  6. data/Gemfile +8 -4
  7. data/NEWS +1 -1
  8. data/README.md +51 -10
  9. data/Rakefile +6 -8
  10. data/features/basic_integration.feature +5 -5
  11. data/features/step_definitions/attachment_steps.rb +4 -4
  12. data/features/step_definitions/rails_steps.rb +4 -4
  13. data/features/step_definitions/web_steps.rb +2 -2
  14. data/features/support/env.rb +2 -2
  15. data/features/support/fixtures/gemfile.txt +1 -1
  16. data/features/support/rails.rb +2 -1
  17. data/gemfiles/3.2.gemfile +5 -3
  18. data/gemfiles/4.0.gemfile +5 -3
  19. data/gemfiles/4.1.gemfile +5 -3
  20. data/lib/generators/paperclip/paperclip_generator.rb +0 -2
  21. data/lib/generators/paperclip/templates/paperclip_migration.rb.erb +1 -1
  22. data/lib/paperclip.rb +4 -1
  23. data/lib/paperclip/attachment.rb +90 -29
  24. data/lib/paperclip/content_type_detector.rb +1 -1
  25. data/lib/paperclip/geometry_detector_factory.rb +3 -1
  26. data/lib/paperclip/has_attached_file.rb +2 -1
  27. data/lib/paperclip/interpolations.rb +8 -0
  28. data/lib/paperclip/io_adapters/abstract_adapter.rb +1 -1
  29. data/lib/paperclip/io_adapters/data_uri_adapter.rb +1 -1
  30. data/lib/paperclip/io_adapters/stringio_adapter.rb +5 -11
  31. data/lib/paperclip/locales/de.yml +18 -0
  32. data/lib/paperclip/locales/es.yml +18 -0
  33. data/lib/paperclip/matchers/have_attached_file_matcher.rb +2 -1
  34. data/lib/paperclip/matchers/validate_attachment_presence_matcher.rb +2 -1
  35. data/lib/paperclip/matchers/validate_attachment_size_matcher.rb +2 -1
  36. data/lib/paperclip/media_type_spoof_detector.rb +10 -2
  37. data/lib/paperclip/storage/filesystem.rb +1 -1
  38. data/lib/paperclip/storage/s3.rb +26 -4
  39. data/lib/paperclip/style.rb +1 -1
  40. data/lib/paperclip/thumbnail.rb +6 -6
  41. data/lib/paperclip/validators.rb +5 -3
  42. data/lib/paperclip/validators/attachment_size_validator.rb +7 -3
  43. data/lib/paperclip/version.rb +1 -1
  44. data/lib/tasks/paperclip.rake +1 -2
  45. data/paperclip.gemspec +5 -3
  46. data/shoulda_macros/paperclip.rb +0 -1
  47. data/{test → spec}/database.yml +0 -0
  48. data/spec/paperclip/attachment_definitions_spec.rb +13 -0
  49. data/{test/attachment_processing_test.rb → spec/paperclip/attachment_processing_spec.rb} +20 -21
  50. data/{test/attachment_registry_test.rb → spec/paperclip/attachment_registry_spec.rb} +10 -11
  51. data/{test/attachment_test.rb → spec/paperclip/attachment_spec.rb} +367 -360
  52. data/{test/content_type_detector_test.rb → spec/paperclip/content_type_detector_spec.rb} +8 -8
  53. data/{test/file_command_content_type_detector_test.rb → spec/paperclip/file_command_content_type_detector_spec.rb} +5 -5
  54. data/spec/paperclip/filename_cleaner_spec.rb +14 -0
  55. data/spec/paperclip/geometry_detector_spec.rb +39 -0
  56. data/{test/geometry_parser_test.rb → spec/paperclip/geometry_parser_spec.rb} +27 -27
  57. data/{test/geometry_test.rb → spec/paperclip/geometry_spec.rb} +49 -51
  58. data/{test/has_attached_file_test.rb → spec/paperclip/has_attached_file_spec.rb} +18 -27
  59. data/{test/integration_test.rb → spec/paperclip/integration_spec.rb} +134 -126
  60. data/{test/interpolations_test.rb → spec/paperclip/interpolations_spec.rb} +54 -40
  61. data/{test/io_adapters/abstract_adapter_test.rb → spec/paperclip/io_adapters/abstract_adapter_spec.rb} +21 -10
  62. data/{test/io_adapters/attachment_adapter_test.rb → spec/paperclip/io_adapters/attachment_adapter_spec.rb} +27 -29
  63. data/{test/io_adapters/data_uri_adapter_test.rb → spec/paperclip/io_adapters/data_uri_adapter_spec.rb} +22 -18
  64. data/spec/paperclip/io_adapters/empty_string_adapter_spec.rb +17 -0
  65. data/{test/io_adapters/file_adapter_test.rb → spec/paperclip/io_adapters/file_adapter_spec.rb} +32 -28
  66. data/{test/io_adapters/http_url_proxy_adapter_test.rb → spec/paperclip/io_adapters/http_url_proxy_adapter_spec.rb} +22 -22
  67. data/spec/paperclip/io_adapters/identity_adapter_spec.rb +8 -0
  68. data/{test/io_adapters/nil_adapter_test.rb → spec/paperclip/io_adapters/nil_adapter_spec.rb} +7 -7
  69. data/{test/io_adapters/registry_test.rb → spec/paperclip/io_adapters/registry_spec.rb} +10 -7
  70. data/{test/io_adapters/stringio_adapter_test.rb → spec/paperclip/io_adapters/stringio_adapter_spec.rb} +16 -17
  71. data/{test/io_adapters/uploaded_file_adapter_test.rb → spec/paperclip/io_adapters/uploaded_file_adapter_spec.rb} +41 -41
  72. data/{test/io_adapters/uri_adapter_test.rb → spec/paperclip/io_adapters/uri_adapter_spec.rb} +22 -22
  73. data/spec/paperclip/matchers/have_attached_file_matcher_spec.rb +19 -0
  74. data/spec/paperclip/matchers/validate_attachment_content_type_matcher_spec.rb +99 -0
  75. data/spec/paperclip/matchers/validate_attachment_presence_matcher_spec.rb +69 -0
  76. data/spec/paperclip/matchers/validate_attachment_size_matcher_spec.rb +88 -0
  77. data/{test/media_type_spoof_detector_test.rb → spec/paperclip/media_type_spoof_detector_spec.rb} +13 -8
  78. data/spec/paperclip/meta_class_spec.rb +30 -0
  79. data/spec/paperclip/paperclip_missing_attachment_styles_spec.rb +84 -0
  80. data/{test/paperclip_test.rb → spec/paperclip/paperclip_spec.rb} +47 -47
  81. data/{test/plural_cache_test.rb → spec/paperclip/plural_cache_spec.rb} +6 -6
  82. data/{test/processor_test.rb → spec/paperclip/processor_spec.rb} +5 -5
  83. data/{test/rake_test.rb → spec/paperclip/rake_spec.rb} +15 -15
  84. data/spec/paperclip/schema_spec.rb +206 -0
  85. data/{test/storage/filesystem_test.rb → spec/paperclip/storage/filesystem_spec.rb} +18 -18
  86. data/{test/storage/fog_test.rb → spec/paperclip/storage/fog_spec.rb} +145 -140
  87. data/spec/paperclip/storage/s3_live_spec.rb +182 -0
  88. data/spec/paperclip/storage/s3_spec.rb +1475 -0
  89. data/spec/paperclip/style_spec.rb +255 -0
  90. data/spec/paperclip/tempfile_factory_spec.rb +29 -0
  91. data/{test/thumbnail_test.rb → spec/paperclip/thumbnail_spec.rb} +107 -107
  92. data/{test/url_generator_test.rb → spec/paperclip/url_generator_spec.rb} +55 -56
  93. data/spec/paperclip/validators/attachment_content_type_validator_spec.rb +322 -0
  94. data/spec/paperclip/validators/attachment_file_name_validator_spec.rb +160 -0
  95. data/{test/validators/attachment_presence_validator_test.rb → spec/paperclip/validators/attachment_presence_validator_spec.rb} +19 -19
  96. data/{test/validators/attachment_size_validator_test.rb → spec/paperclip/validators/attachment_size_validator_spec.rb} +65 -58
  97. data/{test/validators/media_type_spoof_detection_validator_test.rb → spec/paperclip/validators/media_type_spoof_detection_validator_spec.rb} +8 -8
  98. data/spec/paperclip/validators_spec.rb +164 -0
  99. data/spec/spec_helper.rb +40 -0
  100. data/spec/support/assertions.rb +71 -0
  101. data/spec/support/fake_model.rb +21 -0
  102. data/spec/support/fake_rails.rb +12 -0
  103. data/{test → spec/support}/fixtures/12k.png +0 -0
  104. data/{test → spec/support}/fixtures/50x50.png +0 -0
  105. data/{test → spec/support}/fixtures/5k.png +0 -0
  106. data/{test → spec/support}/fixtures/animated +0 -0
  107. data/{test → spec/support}/fixtures/animated.gif +0 -0
  108. data/{test → spec/support}/fixtures/animated.unknown +0 -0
  109. data/{test → spec/support}/fixtures/bad.png +0 -0
  110. data/{test → spec/support}/fixtures/empty.html +0 -0
  111. data/{test → spec/support}/fixtures/fog.yml +0 -0
  112. data/{test → spec/support}/fixtures/rotated.jpg +0 -0
  113. data/{test → spec/support}/fixtures/s3.yml +0 -0
  114. data/spec/support/fixtures/spaced file.jpg +0 -0
  115. data/test/fixtures/spaced file.png b/data/spec/support/fixtures/spaced → file.png +0 -0
  116. data/{test → spec/support}/fixtures/text.txt +0 -0
  117. data/{test → spec/support}/fixtures/twopage.pdf +0 -0
  118. data/{test → spec/support}/fixtures/uppercase.PNG +0 -0
  119. data/spec/support/matchers/accept.rb +5 -0
  120. data/spec/support/matchers/exist.rb +5 -0
  121. data/{test → spec}/support/mock_attachment.rb +0 -0
  122. data/{test → spec}/support/mock_interpolator.rb +0 -0
  123. data/{test → spec}/support/mock_model.rb +0 -0
  124. data/{test → spec}/support/mock_url_generator_builder.rb +0 -0
  125. data/spec/support/model_reconstruction.rb +60 -0
  126. data/spec/support/rails_helpers.rb +7 -0
  127. data/spec/support/test_data.rb +13 -0
  128. data/spec/support/version_helper.rb +9 -0
  129. metadata +256 -210
  130. data/gemfiles/3.0.gemfile +0 -11
  131. data/gemfiles/3.1.gemfile +0 -11
  132. data/test/attachment_definitions_test.rb +0 -13
  133. data/test/filename_cleaner_test.rb +0 -14
  134. data/test/generator_test.rb +0 -84
  135. data/test/geometry_detector_test.rb +0 -24
  136. data/test/helper.rb +0 -239
  137. data/test/io_adapters/empty_string_adapter_test.rb +0 -18
  138. data/test/io_adapters/identity_adapter_test.rb +0 -8
  139. data/test/matchers/have_attached_file_matcher_test.rb +0 -25
  140. data/test/matchers/validate_attachment_content_type_matcher_test.rb +0 -111
  141. data/test/matchers/validate_attachment_presence_matcher_test.rb +0 -70
  142. data/test/matchers/validate_attachment_size_matcher_test.rb +0 -87
  143. data/test/meta_class_test.rb +0 -32
  144. data/test/paperclip_missing_attachment_styles_test.rb +0 -90
  145. data/test/schema_test.rb +0 -206
  146. data/test/storage/s3_live_test.rb +0 -179
  147. data/test/storage/s3_test.rb +0 -1357
  148. data/test/style_test.rb +0 -251
  149. data/test/tempfile_factory_test.rb +0 -29
  150. data/test/validators/attachment_content_type_validator_test.rb +0 -324
  151. data/test/validators/attachment_file_name_validator_test.rb +0 -162
  152. data/test/validators_test.rb +0 -101
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b280fe3ddac312ba397836a6dbb268f3119b741a
4
- data.tar.gz: 9034cfd55c882ef8c2b50ac8e98ccbcd212c746a
3
+ metadata.gz: cde0e56042ab5bd075c28a79c6fb2cac0948b01a
4
+ data.tar.gz: f690007f67429569502696dcd1b1601cfdb8aaf5
5
5
  SHA512:
6
- metadata.gz: 4def9d053ea08b067da60d48e548bdaeaedd2e8c1e82d3b8228857d253313ea105484d9c894edab7803d4a08569b7fc44d69a05fd221c3e8b234004075ec46be
7
- data.tar.gz: d7694572fa8b724c945496299fc916c2e410acf617de7272e7c03218da1140eb8cfc67736a2c02c16afde04b957ad1626ef815a14b2a7c59591c3de5a67ededa
6
+ metadata.gz: af5c881ab7c95be7c42bd61a9db37be53e8a50399e01371286d784ae543b339b16959e2c9327f771c12ee89b47769e86bcd989e67417b93a6093c0592f62ea82
7
+ data.tar.gz: 39d1b2daf02a337b137a4a289a337d898578eaa6997bebdc25f107fc2147677a539815da7d11e516fcbf8ddd6e6f403dbf97c8df205d2db194a89d9b58f15fa4
data/.gitignore CHANGED
@@ -7,12 +7,6 @@ tmp
7
7
 
8
8
  *.log
9
9
 
10
- test/s3.yml
11
- test/paperclip.db
12
- test/doc
13
- test/pkg
14
- test/tmp
15
-
16
10
  public
17
11
  paperclip*.gem
18
12
  capybara*.html
@@ -1,20 +1,17 @@
1
1
  rvm:
2
- - 1.9.2
3
2
  - 1.9.3
4
3
  - jruby-19mode
5
- - rbx-19mode
4
+ - rbx-2
6
5
  - 2.0.0
7
- - 2.1.0
6
+ - 2.1.1
8
7
 
9
8
  install:
10
9
  - "travis_retry bundle install"
11
10
 
12
11
  before_script: "sudo ntpdate -ub ntp.ubuntu.com pool.ntp.org; true"
13
- script: "bundle exec rake clean test cucumber"
12
+ script: "bundle exec rake clean spec cucumber"
14
13
 
15
14
  gemfile:
16
- - gemfiles/3.0.gemfile
17
- - gemfiles/3.1.gemfile
18
15
  - gemfiles/3.2.gemfile
19
16
  - gemfiles/4.0.gemfile
20
17
  - gemfiles/4.1.gemfile
@@ -23,10 +20,4 @@ matrix:
23
20
  fast_finish: true
24
21
  allow_failures:
25
22
  - rvm: jruby-19mode
26
- - rvm: rbx-19mode
27
-
28
- exclude:
29
- - rvm: 1.9.2
30
- gemfile: gemfiles/4.0.gemfile
31
- - rvm: 1.9.2
32
- gemfile: gemfiles/4.1.gemfile
23
+ - rvm: rbx-2
data/Appraisals CHANGED
@@ -1,13 +1,3 @@
1
- appraise "3.0" do
2
- gem "rails", "~> 3.0.20"
3
- gem "paperclip", :path => "../"
4
- end
5
-
6
- appraise "3.1" do
7
- gem "rails", "~> 3.1.12"
8
- gem "paperclip", :path => "../"
9
- end
10
-
11
1
  appraise "3.2" do
12
2
  gem "rails", "~> 3.2.15"
13
3
  gem "paperclip", :path => "../"
@@ -17,8 +17,9 @@ a test!
17
17
  5. Push to your fork and submit a pull request.
18
18
 
19
19
  At this point you're waiting on us. We like to at least comment on, if not
20
- accept, pull requests within three business days (and, typically, one business
21
- day). We may suggest some changes or improvements or alternatives.
20
+ accept, pull requests within seven business days (most of the work on Paperclip
21
+ gets done on Fridays). We may suggest some changes or improvements or
22
+ alternatives.
22
23
 
23
24
  Some things that will increase the chance that your pull request is accepted,
24
25
  taken straight from the Ruby on Rails guide:
@@ -35,6 +36,10 @@ Paperclip uses [Appraisal](https://github.com/thoughtbot/appraisal) to aid
35
36
  testing against multiple version of Ruby on Rails. This helps us to make sure
36
37
  that Paperclip performs correctly with them.
37
38
 
39
+ Paperclip also uses [RSpec](http://rspec.info) for its unit tests. If you submit
40
+ tests that are not written for Cucumber or RSpec without a very good reason, you
41
+ will be asked to rewrite them before we'll accept.
42
+
38
43
  ### Bootstrapping your test suite:
39
44
 
40
45
  bundle install
@@ -47,15 +52,15 @@ version of Rails, which defined in `gemfiles/*.gemfile`.
47
52
 
48
53
  bundle exec rake
49
54
 
50
- This will run Test::Unit and Cucumber against all version of Rails
55
+ This will run RSpec and Cucumber against all version of Rails
51
56
 
52
57
  ### To run single Test::Unit or Cucumber test
53
58
 
54
59
  You need to specify a `BUNDLE_GEMFILE` pointing to the gemfile before running
55
60
  the normal test command:
56
61
 
57
- BUNDLE_GEMFILE=gemfiles/3.2.gemfile ruby -Itest test/schema_test.rb
58
- BUNDLE_GEMFILE=gemfiles/3.2.gemfile cucumber features/basic_integration.feature
62
+ BUNDLE_GEMFILE=gemfiles/4.1.gemfile rspec spec/paperclip/attachment_spec.rb
63
+ BUNDLE_GEMFILE=gemfiles/4.1.gemfile cucumber features/basic_integration.feature
59
64
 
60
65
  Syntax
61
66
  ------
data/Gemfile CHANGED
@@ -2,11 +2,15 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'jruby-openssl', :platform => :jruby
6
- gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
5
+ gem 'sqlite3', '1.3.8', :platforms => :ruby
7
6
 
8
- gem 'pry', :platform => :ruby
9
- gem 'pry-byebug', :platform => :ruby
7
+ gem 'jruby-openssl', :platforms => :jruby
8
+ gem 'activerecord-jdbcsqlite3-adapter', :platforms => :jruby
9
+
10
+ gem 'rubysl', :platforms => :rbx
11
+ gem 'racc', :platforms => :rbx
12
+
13
+ gem 'pry'
10
14
 
11
15
  # Hinting at development dependencies
12
16
  # Prevents bundler from taking a long-time to resolve
data/NEWS CHANGED
@@ -1,6 +1,6 @@
1
1
  New in 4.1.1:
2
2
 
3
- * Improvement: Add defauly translations for spoof validation
3
+ * Improvement: Add default translations for spoof validation
4
4
  * Bug Fix: Don't check for spoofs if the file hasn't changed
5
5
  * Bug Fix: Callback chain terminator is different in Rails 4.1, remove warnings
6
6
  * Improvement: Fixed various Ruby warnings
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Paperclip
2
2
  =========
3
3
 
4
- [![Build Status](https://secure.travis-ci.org/thoughtbot/paperclip.png?branch=master)](http://travis-ci.org/thoughtbot/paperclip) [![Dependency Status](https://gemnasium.com/thoughtbot/paperclip.png?travis)](https://gemnasium.com/thoughtbot/paperclip) [![Code Climate](https://codeclimate.com/github/thoughtbot/paperclip.png)](https://codeclimate.com/github/thoughtbot/paperclip)
4
+ [![Build Status](https://secure.travis-ci.org/thoughtbot/paperclip.png?branch=master)](http://travis-ci.org/thoughtbot/paperclip) [![Dependency Status](https://gemnasium.com/thoughtbot/paperclip.png?travis)](https://gemnasium.com/thoughtbot/paperclip) [![Code Climate](https://codeclimate.com/github/thoughtbot/paperclip.png)](https://codeclimate.com/github/thoughtbot/paperclip) [![Inline docs](http://inch-ci.org/github/thoughtbot/paperclip.png)](http://inch-ci.org/github/thoughtbot/paperclip)
5
5
 
6
6
  Paperclip is intended as an easy file attachment library for Active Record. The
7
7
  intent behind it was to keep setup as easy as possible and to treat files as
@@ -55,6 +55,11 @@ GhostScript to be installed. On Mac OS X, you can also install that using Homebr
55
55
 
56
56
  brew install gs
57
57
 
58
+ ### `file` command
59
+
60
+ The Unix [`file` command](http://en.wikipedia.org/wiki/File_(command)) is required for content type checking.
61
+ This utility isn't available in Windows, but comes bundled with Ruby [Devkit](https://github.com/oneclick/rubyinstaller/wiki/Development-Kit),
62
+ so Windows users must make sure that the devkit is installed and added to system `PATH`.
58
63
 
59
64
  Installation
60
65
  ------------
@@ -191,7 +196,7 @@ Usage
191
196
  The basics of paperclip are quite simple: Declare that your model has an
192
197
  attachment with the `has_attached_file` method, and give it a name.
193
198
 
194
- Paperclip will wrap up up to four attributes (all prefixed with that attachment's name,
199
+ Paperclip will wrap up to four attributes (all prefixed with that attachment's name,
195
200
  so you can have multiple attachments per model if you wish) and give them a
196
201
  friendly front end. These attributes are:
197
202
 
@@ -221,6 +226,8 @@ Example Usage:
221
226
  ```ruby
222
227
  validates :avatar, :attachment_presence => true
223
228
  validates_with AttachmentPresenceValidator, :attributes => :avatar
229
+ validates_with AttachmentSizeValidator, :attributes => :avatar, :less_than => 1.megabytes
230
+
224
231
  ```
225
232
 
226
233
  Validators can also be defined using the old helper style:
@@ -239,7 +246,7 @@ Lastly, you can also define multiple validations on a single attachment using `v
239
246
 
240
247
  ```ruby
241
248
  validates_attachment :avatar, :presence => true,
242
- :content_type => { :content_type => "image/jpg" },
249
+ :content_type => { :content_type => "image/jpeg" },
243
250
  :size => { :in => 0..10.kilobytes }
244
251
  ```
245
252
 
@@ -298,7 +305,7 @@ image-y ones:
298
305
 
299
306
  ```ruby
300
307
  validates_attachment :avatar,
301
- :content_type => { :content_type => ["image/jpg", "image/gif", "image/png"] }
308
+ :content_type => { :content_type => ["image/jpeg", "image/gif", "image/png"] }
302
309
  ```
303
310
 
304
311
  `Paperclip::ContentTypeDetector` will attempt to match a file's extension to an
@@ -319,11 +326,11 @@ do this.
319
326
  ```ruby
320
327
  class ActiveRecord::Base
321
328
  has_attached_file :avatar
322
- # Validate content type
329
+ # Validate content type
323
330
  validates_attachment_content_type :avatar, :content_type => /\Aimage/
324
- # Validate filename
331
+ # Validate filename
325
332
  validates_attachment_file_name :avatar, :matches => [/png\Z/, /jpe?g\Z/]
326
- # Explicitly do not validate
333
+ # Explicitly do not validate
327
334
  do_not_validate_attachment_file_type :avatar
328
335
  end
329
336
  ```
@@ -604,6 +611,19 @@ class AddAvatarFingerprintColumnToUser < ActiveRecord::Migration
604
611
  end
605
612
  ```
606
613
 
614
+ File Preservation for Soft-Delete
615
+ -------
616
+
617
+ An option is available to preserve attachments in order to play nicely with soft-deleted models. (acts_as_paranoid, paranoia, etc.)
618
+
619
+ ```ruby
620
+ has_attached_file :some_attachment, {
621
+ :preserve_files => "true",
622
+ }
623
+ ```
624
+
625
+ This will prevent ```some_attachment``` from being wiped out when the model gets destroyed, so it will still exist when the object is restored later.
626
+
607
627
  Custom Attachment Processors
608
628
  -------
609
629
 
@@ -695,12 +715,14 @@ Here is an example for Capistrano:
695
715
  ```ruby
696
716
  namespace :deploy do
697
717
  desc "build missing paperclip styles"
698
- task :build_missing_paperclip_styles, :roles => :app do
699
- run "cd #{release_path}; RAILS_ENV=production bundle exec rake paperclip:refresh:missing_styles"
718
+ task :build_missing_paperclip_styles do
719
+ on roles(:app) do
720
+ execute "cd #{current_path}; RAILS_ENV=production bundle exec rake paperclip:refresh:missing_styles"
721
+ end
700
722
  end
701
723
  end
702
724
 
703
- after("deploy:update_code", "deploy:build_missing_paperclip_styles")
725
+ after("deploy:compile_assets", "deploy:build_missing_paperclip_styles")
704
726
  ```
705
727
 
706
728
  Now you don't have to remember to refresh thumbnails in production every time you add a new style.
@@ -763,6 +785,25 @@ end
763
785
  The important part here being the inclusion of `ENV['TEST_ENV_NUMBER']`, or the
764
786
  similar mechanism for whichever parallel testing library you use.
765
787
 
788
+ **Integration Tests**
789
+
790
+ Using integration tests with FactoryGirl may save multiple copies of
791
+ your test files within the app. To avoid this, specify a custom path in
792
+ the `config/environments/test.rb` like so:
793
+
794
+ ```ruby
795
+ Paperclip::Attachment.default_options[:path] = "#{Rails.root}/spec/test_files/:class/:id_partition/:style.:extension"
796
+ ```
797
+
798
+ Then, make sure to delete that directory after the test suite runs by adding
799
+ this to `spec_helper.rb`.
800
+
801
+ ```ruby
802
+ config.after(:suite) do
803
+ FileUtils.rm_rf(Dir["#{Rails.root}/spec/test_files/"])
804
+ end
805
+ ```
806
+
766
807
  Contributing
767
808
  ------------
768
809
 
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'appraisal'
3
- require 'rake/testtask'
3
+ require 'rspec/core/rake_task'
4
4
  require 'cucumber/rake/task'
5
5
 
6
6
  desc 'Default: run unit tests.'
@@ -9,19 +9,17 @@ task :default => [:clean, :all]
9
9
  desc 'Test the paperclip plugin under all supported Rails versions.'
10
10
  task :all do |t|
11
11
  if ENV['BUNDLE_GEMFILE']
12
- exec('rake test cucumber')
12
+ exec('rake spec cucumber')
13
13
  else
14
+ exec("rm gemfiles/*.lock")
15
+ Rake::Task["appraisal:gemfiles"].execute
14
16
  Rake::Task["appraisal:install"].execute
15
- exec('rake appraisal test cucumber')
17
+ exec('rake appraisal')
16
18
  end
17
19
  end
18
20
 
19
21
  desc 'Test the paperclip plugin.'
20
- Rake::TestTask.new(:test) do |t|
21
- t.libs << 'lib' << 'profile'
22
- t.pattern = 'test/**/*_test.rb'
23
- t.verbose = true
24
- end
22
+ RSpec::Core::RakeTask.new(:spec)
25
23
 
26
24
  desc 'Run integration test'
27
25
  Cucumber::Rake::Task.new do |t|
@@ -18,11 +18,11 @@ Feature: Rails integration
18
18
  And I start the rails application
19
19
  When I go to the new user page
20
20
  And I fill in "Name" with "something"
21
- And I attach the file "test/fixtures/5k.png" to "Attachment"
21
+ And I attach the file "spec/support/fixtures/5k.png" to "Attachment"
22
22
  And I press "Submit"
23
23
  Then I should see "Name: something"
24
24
  And I should see an image with a path of "/paperclip/custom/attachments/original/5k.png"
25
- And the file at "/paperclip/custom/attachments/original/5k.png" should be the same as "test/fixtures/5k.png"
25
+ And the file at "/paperclip/custom/attachments/original/5k.png" should be the same as "spec/support/fixtures/5k.png"
26
26
 
27
27
  Scenario: Filesystem integration test
28
28
  Given I attach :attachment with:
@@ -32,11 +32,11 @@ Feature: Rails integration
32
32
  And I start the rails application
33
33
  When I go to the new user page
34
34
  And I fill in "Name" with "something"
35
- And I attach the file "test/fixtures/5k.png" to "Attachment"
35
+ And I attach the file "spec/support/fixtures/5k.png" to "Attachment"
36
36
  And I press "Submit"
37
37
  Then I should see "Name: something"
38
38
  And I should see an image with a path of "/system/attachments/original/5k.png"
39
- And the file at "/system/attachments/original/5k.png" should be the same as "test/fixtures/5k.png"
39
+ And the file at "/system/attachments/original/5k.png" should be the same as "spec/support/fixtures/5k.png"
40
40
 
41
41
  Scenario: S3 Integration test
42
42
  Given I attach :attachment with:
@@ -55,7 +55,7 @@ Feature: Rails integration
55
55
  And I start the rails application
56
56
  When I go to the new user page
57
57
  And I fill in "Name" with "something"
58
- And I attach the file "test/fixtures/5k.png" to "Attachment" on S3
58
+ And I attach the file "spec/support/fixtures/5k.png" to "Attachment" on S3
59
59
  And I press "Submit"
60
60
  Then I should see "Name: something"
61
61
  And I should see an image with a path of "http://s3.amazonaws.com/paperclip/attachments/original/5k.png"
@@ -1,6 +1,6 @@
1
1
  module AttachmentHelpers
2
2
  def fixture_path(filename)
3
- File.expand_path("#{PROJECT_ROOT}/test/fixtures/#{filename}")
3
+ File.expand_path("#{PROJECT_ROOT}/spec/support/fixtures/#{filename}")
4
4
  end
5
5
 
6
6
  def attachment_path(filename)
@@ -35,7 +35,7 @@ end
35
35
 
36
36
  Then /^the attachment "([^"]*)" should exist$/ do |filename|
37
37
  in_current_dir do
38
- File.exists?(attachment_path(filename)).should be
38
+ File.exist?(attachment_path(filename)).should be
39
39
  end
40
40
  end
41
41
 
@@ -85,7 +85,7 @@ Then /^I should have attachment columns for "([^"]*)"$/ do |attachment_name|
85
85
  ["#{attachment_name}_updated_at", :datetime]
86
86
  ]
87
87
 
88
- expect_columns.all?{ |column| columns.include? column }.should be_true
88
+ expect_columns.all?{ |column| columns.include? column }.should eq true
89
89
  end
90
90
  end
91
91
 
@@ -99,6 +99,6 @@ Then /^I should not have attachment columns for "([^"]*)"$/ do |attachment_name|
99
99
  ["#{attachment_name}_updated_at", :datetime]
100
100
  ]
101
101
 
102
- expect_columns.none?{ |column| columns.include? column }.should be_true
102
+ expect_columns.none?{ |column| columns.include? column }.should eq true
103
103
  end
104
104
  end
@@ -8,18 +8,18 @@ Given /^I generate a new rails application$/ do
8
8
  """
9
9
  source "http://rubygems.org"
10
10
  gem "rails", "#{framework_version}"
11
- gem "sqlite3", :platform => :ruby
11
+ gem "sqlite3", "1.3.8", :platform => [:ruby, :rbx]
12
12
  gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
13
13
  gem "jruby-openssl", :platform => :jruby
14
14
  gem "capybara"
15
15
  gem "gherkin"
16
16
  gem "aws-sdk"
17
+ gem "racc", :platform => :rbx
18
+ gem "rubysl", :platform => :rbx
17
19
  """
18
20
  And I remove turbolinks
19
21
  And I empty the application.js file
20
22
  And I configure the application to use "paperclip" from this project
21
- And I reset Bundler environment variable
22
- And I successfully run `bundle install --local`
23
23
  }
24
24
  end
25
25
 
@@ -197,7 +197,7 @@ Given /^I am using Rails newer than ([\d\.]+)$/ do |version|
197
197
  end
198
198
 
199
199
  def transform_file(filename)
200
- if File.exists?(filename)
200
+ if File.exist?(filename)
201
201
  content = File.read(filename)
202
202
  File.open(filename, "w") do |f|
203
203
  content = yield(content)
@@ -164,7 +164,7 @@ Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, pa
164
164
  with_scope(parent) do
165
165
  field_checked = find_field(label)['checked']
166
166
  if field_checked.respond_to? :should
167
- field_checked.should be_true
167
+ field_checked.should eq true
168
168
  else
169
169
  assert field_checked
170
170
  end
@@ -175,7 +175,7 @@ Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label
175
175
  with_scope(parent) do
176
176
  field_checked = find_field(label)['checked']
177
177
  if field_checked.respond_to? :should
178
- field_checked.should be_false
178
+ field_checked.should eq false
179
179
  else
180
180
  assert !field_checked
181
181
  end
@@ -1,10 +1,10 @@
1
1
  require 'aruba/cucumber'
2
2
  require 'capybara/cucumber'
3
- require 'test/unit/assertions'
3
+ require 'rspec/matchers'
4
4
 
5
5
  $CUCUMBER=1
6
6
 
7
- World(Test::Unit::Assertions)
7
+ World(RSpec::Matchers)
8
8
 
9
9
  Before do
10
10
  @aruba_timeout_seconds = 120
@@ -2,4 +2,4 @@ source "http://rubygems.org"
2
2
 
3
3
  gem "rails", "RAILS_VERSION"
4
4
  gem "rdoc"
5
- gem "sqlite3"
5
+ gem "sqlite3", "1.3.8"