cloudfuji_paperclip 2.4.6 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. data/.gitignore +2 -0
  2. data/.travis.yml +9 -6
  3. data/Appraisals +6 -6
  4. data/CONTRIBUTING.md +34 -2
  5. data/Gemfile +2 -0
  6. data/NEWS +90 -0
  7. data/README.md +62 -29
  8. data/RUNNING_TESTS.md +4 -0
  9. data/Rakefile +7 -2
  10. data/UPGRADING +14 -0
  11. data/features/basic_integration.feature +11 -7
  12. data/features/rake_tasks.feature +1 -1
  13. data/features/step_definitions/attachment_steps.rb +11 -2
  14. data/features/step_definitions/rails_steps.rb +17 -79
  15. data/features/support/env.rb +3 -0
  16. data/features/support/fakeweb.rb +7 -0
  17. data/features/support/file_helpers.rb +24 -0
  18. data/features/support/rails.rb +3 -3
  19. data/gemfiles/{rails3_1.gemfile → 3.0.gemfile} +3 -1
  20. data/gemfiles/{rails2.gemfile → 3.1.gemfile} +3 -1
  21. data/gemfiles/{rails3.gemfile → 3.2.gemfile} +3 -1
  22. data/images.rake +21 -0
  23. data/lib/cloudfuji_paperclip.rb +1 -0
  24. data/lib/generators/paperclip/paperclip_generator.rb +1 -2
  25. data/lib/paperclip.rb +54 -319
  26. data/lib/paperclip/attachment.rb +86 -107
  27. data/lib/paperclip/attachment_options.rb +9 -0
  28. data/lib/paperclip/callbacks.rb +30 -0
  29. data/lib/paperclip/errors.rb +27 -0
  30. data/lib/paperclip/geometry.rb +6 -4
  31. data/lib/paperclip/glue.rb +23 -0
  32. data/lib/paperclip/helpers.rb +71 -0
  33. data/lib/paperclip/instance_methods.rb +35 -0
  34. data/lib/paperclip/interpolations.rb +4 -4
  35. data/lib/paperclip/io_adapters/attachment_adapter.rb +69 -0
  36. data/lib/paperclip/io_adapters/file_adapter.rb +81 -0
  37. data/lib/paperclip/io_adapters/identity_adapter.rb +12 -0
  38. data/lib/paperclip/io_adapters/nil_adapter.rb +34 -0
  39. data/lib/paperclip/io_adapters/registry.rb +32 -0
  40. data/lib/paperclip/io_adapters/stringio_adapter.rb +64 -0
  41. data/lib/paperclip/io_adapters/uploaded_file_adapter.rb +63 -0
  42. data/lib/paperclip/locales/en.yml +17 -0
  43. data/lib/paperclip/logger.rb +21 -0
  44. data/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb +5 -5
  45. data/lib/paperclip/matchers/validate_attachment_presence_matcher.rb +7 -7
  46. data/lib/paperclip/matchers/validate_attachment_size_matcher.rb +11 -11
  47. data/lib/paperclip/missing_attachment_styles.rb +6 -9
  48. data/lib/paperclip/processor.rb +32 -17
  49. data/lib/paperclip/railtie.rb +13 -17
  50. data/lib/paperclip/storage/filesystem.rb +4 -13
  51. data/lib/paperclip/storage/fog.rb +33 -24
  52. data/lib/paperclip/storage/s3.rb +36 -28
  53. data/lib/paperclip/tempfile.rb +41 -0
  54. data/lib/paperclip/thumbnail.rb +2 -3
  55. data/lib/paperclip/validators.rb +45 -0
  56. data/lib/paperclip/validators/attachment_content_type_validator.rb +54 -0
  57. data/lib/paperclip/validators/attachment_presence_validator.rb +26 -0
  58. data/lib/paperclip/validators/attachment_size_validator.rb +102 -0
  59. data/lib/paperclip/version.rb +1 -1
  60. data/lib/tasks/paperclip.rake +4 -12
  61. data/paperclip.gemspec +15 -5
  62. data/test/adapter_registry_test.rb +32 -0
  63. data/test/attachment_adapter_test.rb +51 -0
  64. data/test/attachment_options_test.rb +27 -0
  65. data/test/attachment_test.rb +130 -46
  66. data/test/file_adapter_test.rb +88 -0
  67. data/test/generator_test.rb +78 -0
  68. data/test/geometry_test.rb +5 -5
  69. data/test/helper.rb +21 -22
  70. data/test/identity_adapter_test.rb +8 -0
  71. data/test/integration_test.rb +55 -102
  72. data/test/interpolations_test.rb +15 -5
  73. data/test/matchers/validate_attachment_content_type_matcher_test.rb +23 -0
  74. data/test/matchers/validate_attachment_presence_matcher_test.rb +21 -0
  75. data/test/matchers/validate_attachment_size_matcher_test.rb +37 -2
  76. data/test/nil_adapter_test.rb +25 -0
  77. data/test/paperclip_missing_attachment_styles_test.rb +16 -0
  78. data/test/paperclip_test.rb +34 -183
  79. data/test/storage/filesystem_test.rb +27 -27
  80. data/test/storage/fog_test.rb +68 -12
  81. data/test/storage/s3_live_test.rb +79 -38
  82. data/test/storage/s3_test.rb +204 -34
  83. data/test/stringio_adapter_test.rb +42 -0
  84. data/test/thumbnail_test.rb +29 -8
  85. data/test/uploaded_file_adapter_test.rb +98 -0
  86. data/test/url_generator_test.rb +8 -8
  87. data/test/validators/attachment_content_type_validator_test.rb +192 -0
  88. data/test/validators/attachment_presence_validator_test.rb +85 -0
  89. data/test/validators/attachment_size_validator_test.rb +207 -0
  90. data/test/validators_test.rb +25 -0
  91. metadata +166 -59
  92. data/generators/paperclip/USAGE +0 -5
  93. data/generators/paperclip/paperclip_generator.rb +0 -27
  94. data/generators/paperclip/templates/paperclip_migration.rb.erb +0 -19
  95. data/init.rb +0 -4
  96. data/lib/paperclip/callback_compatibility.rb +0 -61
  97. data/lib/paperclip/iostream.rb +0 -45
  98. data/lib/paperclip/upfile.rb +0 -62
  99. data/rails/init.rb +0 -2
  100. data/test/.gitignore +0 -1
  101. data/test/fixtures/question?mark.png +0 -0
  102. data/test/iostream_test.rb +0 -71
  103. data/test/upfile_test.rb +0 -53
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .rvmrc
4
4
  .bundle
5
5
  tmp
6
+ .DS_Store
6
7
 
7
8
  test/s3.yml
8
9
  test/debug.log
@@ -20,3 +21,4 @@ capybara*.html
20
21
 
21
22
  *SPIKE*
22
23
  *emfile.lock
24
+ tags
@@ -1,13 +1,16 @@
1
1
  rvm:
2
- - 1.8.7
3
2
  - 1.9.2
4
- - ree
5
- - rbx-2.0
3
+ - 1.9.3
4
+ - jruby-19mode
6
5
 
7
6
  before_script: "sudo ntpdate -ub ntp.ubuntu.com pool.ntp.org; true"
8
7
  script: "bundle exec rake clean test cucumber"
9
8
 
10
9
  gemfile:
11
- - gemfiles/rails2.gemfile
12
- - gemfiles/rails3.gemfile
13
- - gemfiles/rails3_1.gemfile
10
+ - gemfiles/3.0.gemfile
11
+ - gemfiles/3.1.gemfile
12
+ - gemfiles/3.2.gemfile
13
+
14
+ matrix:
15
+ allow_failures:
16
+ - rvm: jruby-19mode
data/Appraisals CHANGED
@@ -1,14 +1,14 @@
1
- appraise "rails2" do
2
- gem "rails", "~> 2.3.14"
1
+ appraise "3.0" do
2
+ gem "rails", "~> 3.0.12"
3
3
  gem "paperclip", :path => "../"
4
4
  end
5
5
 
6
- appraise "rails3" do
7
- gem "rails", "~> 3.0.10"
6
+ appraise "3.1" do
7
+ gem "rails", "~> 3.1.4"
8
8
  gem "paperclip", :path => "../"
9
9
  end
10
10
 
11
- appraise "rails3_1" do
12
- gem "rails", "~> 3.1.0"
11
+ appraise "3.2" do
12
+ gem "rails", "~> 3.2.2"
13
13
  gem "paperclip", :path => "../"
14
14
  end
@@ -1,3 +1,6 @@
1
+ Contributing
2
+ ============
3
+
1
4
  We love pull requests. Here's a quick guide:
2
5
 
3
6
  1. Fork the repo.
@@ -13,7 +16,6 @@ a test!
13
16
 
14
17
  5. Push to your fork and submit a pull request.
15
18
 
16
-
17
19
  At this point you're waiting on us. We like to at least comment on, if not
18
20
  accept, pull requests within three business days (and, typically, one business
19
21
  day). We may suggest some changes or improvements or alternatives.
@@ -26,7 +28,37 @@ taken straight from the Ruby on Rails guide:
26
28
  * Update the documentation, the surrounding one, examples elsewhere, guides,
27
29
  whatever is affected by your contribution
28
30
 
29
- Syntax:
31
+ Running Tests
32
+ -------------
33
+
34
+ Paperclip uses [Appraisal](https://github.com/thoughtbot/appraisal) to aid
35
+ testing against multiple version of Ruby on Rails. This helps us to make sure
36
+ that Paperclip performs correctly with them.
37
+
38
+ ### Bootstrapping your test suite:
39
+
40
+ bundle install
41
+ bundle exec rake appraisal:install
42
+
43
+ This will install all the required gems that requires to test against each
44
+ version of Rails, which defined in `gemfiles/*.gemfile`.
45
+
46
+ ### To run a full test suite:
47
+
48
+ bundle exec rake
49
+
50
+ This will run Test::Unit and Cucumber against all version of Rails
51
+
52
+ ### To run single Test::Unit or Cucumber test
53
+
54
+ You need to specify a `BUNDLE_GEMFILE` pointing to the gemfile before running
55
+ the normal test command:
56
+
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
59
+
60
+ Syntax
61
+ ------
30
62
 
31
63
  * Two spaces, no tabs.
32
64
  * No trailing whitespace. Blank lines should not have any space.
data/Gemfile CHANGED
@@ -3,3 +3,5 @@ source "http://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  gem "jruby-openssl", :platform => :jruby
6
+ gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
7
+ gem "sqlite3", :platform => :ruby
data/NEWS ADDED
@@ -0,0 +1,90 @@
1
+ Unreleased:
2
+
3
+ * Bug fix: AttachmentContentTypeValidator now allow you to specify :allow_blank/:allow_nil
4
+ * Bug fix: Make sure content type always a String.
5
+ * Bug fix: Fix attachment.reprocess! when using storage providers fog and s3.
6
+ * Bug fix: Fix a problem with incorrect content_type detected with 'file' command for an empty file on Mac.
7
+
8
+ New in 3.0.2:
9
+
10
+ * API CHANGE: Generated migration class name is now plural (AddAttachmentToUsers instead of AddAttachmentToUser)
11
+ * API CHANGE: Remove Rails plugin initialization code.
12
+ * API CHANGE: Explicitly require Ruby 1.9.2 in the Gemfile.
13
+ * Bug fix: Fixes AWS::S3::Errors::RequestTimeout on Model#save.
14
+ * Bug fix: Fix a problem when there's no logger specified.
15
+ * Bug fix: Fix a problem when attaching Rack::Test::UploadedFile instance.
16
+
17
+ New in 3.0.1:
18
+
19
+ * Feature: Introduce Paperlip IO adapter.
20
+ * Bug fix: Regression in AttachmentContentTypeValidator has been fixed.
21
+
22
+ New in 3.0.0:
23
+
24
+ * API CHANGE: Paperclip now requires at least Ruby on Rails version 3.0.0
25
+ * API CHANGE: The default :url and :path have changed. The new scheme avoids
26
+ filesystem conflicts and scales to handle larger numbers of uploads.
27
+
28
+ The easiest way to upgrade is to add an explicit :url and :path to your
29
+ has_attached_file calls:
30
+
31
+ has_attached_file :avatar,
32
+ :path => ":rails_root/public/system/:attachment/:id/:style/:filename",
33
+ :url => "/system/:attachment/:id/:style/:filename"
34
+
35
+ * Feature: Adding Rails 3 style validators, and adding `validates_attachment` method as a shorthand.
36
+ * Bug fix: Paperclip's rake tasks now loading records in batch.
37
+ * Bug fix: Attachment style name with leading number now not raising an error.
38
+ * Bug fix: File given to S3 and Fog storage will now be rewinded after flush_write.
39
+ * Feature: You can now pass addional parameter to S3 expiring URL, such as :content_type.
40
+
41
+ New in 2.7.0:
42
+
43
+ * Bug fix: Checking the existence of a file on S3 handles all AWS errors.
44
+ * Bug fix: Clear the fingerprint when removing an attachment.
45
+ * Bug fix: Attachment size validation message reads more nicely now.
46
+ * Feature: Style names can be either symbols or strings.
47
+ * Compatibility: Support for ActiveSupport < 2.3.12.
48
+ * Compatibility: Support for Rails 3.2.
49
+
50
+ New in 2.6.0:
51
+
52
+ * Bug fix: Files are re-wound after reading.
53
+ * Feature: Remove Rails dependency from specs that need Paperclip.
54
+ * Feature: Validation matchers support conditionals.
55
+
56
+ New in 2.5.2:
57
+
58
+ * Bug fix: Can be installed on Windows.
59
+ * Feature: The Fog bucket name, authentication, and host can be determined at runtime via Proc.
60
+ * Feature: Special characters are replaced with underscores in #url and #path.
61
+
62
+ New in 2.5.1:
63
+
64
+ * Feature: After we've computed the content type, pass it to Fog.
65
+ * Feature: S3 encryption with the new :s3_server_side_encryption option.
66
+ * Feature: Works without ActiveRecord, allowing for e.g. mongo backends.
67
+
68
+ New in 2.5.0:
69
+
70
+ * Performance: Only connect to S3 when absolutely needed.
71
+ * Bug fix: STI with cached classes respect new options.
72
+ * Bug fix: conditional validations broke, and now work again.
73
+ * Feature: URL generation is now parameterized and can be changed with plugins or custom code.
74
+ * Feature: :convert_options and :source_file_options to control the ImageMagick processing.
75
+ * Performance: String geometry specifications now parse more quickly.
76
+ * Bug fix: Handle files with question marks in the filename.
77
+ * Bug fix: Don't raise an error when generating an expiring URL on an unassigned attachment.
78
+ * Bug fix: The rake task runs over all instances of an ActiveRecord model, ignoring default scopes.
79
+ * Feature: DB migration has_attached_file and drop_attached_file methods.
80
+ * Bug fix: Switch from AWS::S3 to AWS::SDK for the S3 backend.
81
+ * Bug fix: URL generator uses '?' in the URL unless it already appears and there is no prior '='.
82
+ * Bug fix: Always convert the content type to a string before stripping blanks.
83
+ * Feature: The :keep_old_files option preserves the files in storage even when the attachment is cleared or changed.
84
+ * Performance: Optimize Fog's public_url access by avoiding it when possible.
85
+ * Bug fix: Avoid a runtime error when generating the ID partition for an unsaved attachment.
86
+ * Performance: Do not calculate the fingerprint if it is never persisted.
87
+ * Bug fix: Process the :original style before all others, in case of a dependency.
88
+ * Feature: S3 headers can be set at runtime by passing a proc object as the value.
89
+ * Bug fix: Generating missing attachment styles for a model which has had its attachment changed should not raise.
90
+ * Bug fix: Do not collide with the built-in Ruby hashing method.
data/README.md CHANGED
@@ -24,7 +24,15 @@ The complete [RDoc](http://rdoc.info/gems/paperclip) is online.
24
24
  Requirements
25
25
  ------------
26
26
 
27
- ImageMagick must be installed and Paperclip must have access to it. To ensure
27
+ ### Ruby and Rails
28
+
29
+ Paperclip now requires Ruby version **>= 1.9.2** and Rails version **>= 3.0** (Only if you're going to use Paperclip with Ruby on Rails.)
30
+
31
+ If you're still on Ruby 1.8.7 or Ruby on Rails 2.3.x, you can still use Paperclip 2.7.x with your project. Also, everything in this README might not apply to your version of Paperclip, and you should read [the README for version 2.7](http://rubydoc.info/gems/paperclip/2.7.0) instead.
32
+
33
+ ### Image Processor
34
+
35
+ [ImageMagick](http://www.imagemagick.org) must be installed and Paperclip must have access to it. To ensure
28
36
  that it does, on your command line, run `which convert` (one of the ImageMagick
29
37
  utilities). This will give you the path where that utility is installed. For
30
38
  example, it might return `/usr/local/bin/convert`.
@@ -49,33 +57,25 @@ GhostScript to be installed. On Mac OS X, you can also install that using Homebr
49
57
  Installation
50
58
  ------------
51
59
 
52
- Paperclip is distributed as a gem, which is how it should be used in your app. It's
53
- technically still installable as a plugin, but that's discouraged, as Rails plays
54
- well with gems.
60
+ Paperclip is distributed as a gem, which is how it should be used in your app.
55
61
 
56
62
  Include the gem in your Gemfile:
57
63
 
58
- gem "paperclip", "~> 2.0"
64
+ gem "paperclip", "~> 3.0"
65
+
66
+ If you're still using Rails 2.3.x, you should do this instead:
67
+
68
+ gem "paperclip", "~> 2.7"
59
69
 
60
70
  Or, if you want to get the latest, you can get master from the main paperclip repository:
61
71
 
62
72
  gem "paperclip", :git => "git://github.com/thoughtbot/paperclip.git"
63
-
73
+
64
74
  If you're trying to use features that don't seem to be in the latest released gem, but are
65
75
  mentioned in this README, then you probably need to specify the master branch if you want to
66
76
  use them. This README is probably ahead of the latest released version, if you're reading it
67
77
  on GitHub.
68
78
 
69
- Anyway, if you don't use Bundler (though you probably should, even in Rails 2), with config.gem
70
-
71
- # In config/environment.rb
72
- ...
73
- Rails::Initializer.run do |config|
74
- ...
75
- config.gem "paperclip", :version => "~> 2.4"
76
- ...
77
- end
78
-
79
79
  For Non-Rails usage:
80
80
 
81
81
  class ModuleName < ActiveRecord::Base
@@ -106,6 +106,8 @@ In your migrations:
106
106
  end
107
107
  end
108
108
 
109
+ (Or you can use migration generator: `rails generate paperclip user avatar`)
110
+
109
111
  In your edit and new views:
110
112
 
111
113
  <%= form_for :user, @user, :url => user_path, :html => { :multipart => true } do |form| %>
@@ -151,12 +153,33 @@ validation.
151
153
  More information about the options to `has_attached_file` is available in the
152
154
  documentation of [`Paperclip::ClassMethods`](http://rubydoc.info/gems/paperclip/Paperclip/ClassMethods).
153
155
 
154
- For validations, attachments can be validated with these Paperclip's validation methods:
156
+ For validations, Paperclip introduces several validators to validate your attachment:
157
+
158
+ * `AttachmentContentTypeValidator`
159
+ * `AttachmentPresenceValidator`
160
+ * `AttachmentSizeValidator`
161
+
162
+ Example Usage:
163
+
164
+ validates :avatar, :attachment_presence => true
165
+ validates_with AttachmentPresenceValidator, :attributes => :avatar
166
+
167
+ Validators can also be defined using the old helper style:
155
168
 
156
169
  * `validates_attachment_presence`
157
170
  * `validates_attachment_content_type`
158
171
  * `validates_attachment_size`
159
172
 
173
+ Example Usage:
174
+
175
+ validates_attachment_presence :avatar
176
+
177
+ Lastly, you can also define multiple validations on a single attachment using `validates_attachment`:
178
+
179
+ validates_attachment :avatar, :presence => true,
180
+ :content_type => { :content_type => "image/jpg" },
181
+ :size => { :in => 0..10.kilobytes }
182
+
160
183
  Storage
161
184
  -------
162
185
 
@@ -176,9 +199,9 @@ safer choice for the default file store._
176
199
  You may also choose to store your files using Amazon's S3 service. To do so, include
177
200
  the `aws-sdk` gem in your Gemfile:
178
201
 
179
- gem 'aws-sdk'
202
+ gem 'aws-sdk', '~> 1.3.4'
180
203
 
181
- And then you can specify using S3 from `has_attached_file`.
204
+ And then you can specify using S3 from `has_attached_file`.
182
205
  You can find more information about configuring and using S3 storage in
183
206
  [the `Paperclip::Storage::S3` documentation](http://rubydoc.info/gems/paperclip/Paperclip/Storage/S3).
184
207
 
@@ -199,9 +222,9 @@ thumbnail images. By defining a subclass of Paperclip::Processor, you can
199
222
  perform any processing you want on the files that are attached. Any file in
200
223
  your Rails app's lib/paperclip\_processors directory is automatically loaded by
201
224
  paperclip, allowing you to easily define custom processors. You can specify a
202
- processor with the :processors option to has\_attached\_file:
225
+ processor with the :processors option to `has_attached_file`:
203
226
 
204
- has_attached\_file :scan, :styles => { :text => { :quality => :better } },
227
+ has_attached_file :scan, :styles => { :text => { :quality => :better } },
205
228
  :processors => [:ocr]
206
229
 
207
230
  This would load the hypothetical class Paperclip::Ocr, which would have the
@@ -217,7 +240,7 @@ geometry and a format, which the file will be converted to, like so:
217
240
  This will convert the "thumb" style to a 32x32 square in png format, regardless
218
241
  of what was uploaded. If the format is not specified, it is kept the same (i.e.
219
242
  jpgs will remain jpgs). For more information on the accepted style formats, see
220
- [http://www.imagemagick.org/script/command-line-processing.php#geometry](here).
243
+ [here](http://www.imagemagick.org/script/command-line-processing.php#geometry).
221
244
 
222
245
  Multiple processors can be specified, and they will be invoked in the order
223
246
  they are defined in the :processors array. Each successive processor will
@@ -251,14 +274,24 @@ are called before and after the processing of each attachment), and the
251
274
  attachment-specific `before_<attachment>_post_process` and
252
275
  `after_<attachment>_post_process`. The callbacks are intended to be as close to
253
276
  normal ActiveRecord callbacks as possible, so if you return false (specifically
254
- \- returning nil is not the same) in a before\_ filter, the post processing step
255
- will halt. Returning false in an after\_ filter will not halt anything, but you
277
+ \- returning nil is not the same) in a `before_filter`, the post processing step
278
+ will halt. Returning false in an `after_filter` will not halt anything, but you
256
279
  can access the model and the attachment if necessary.
257
280
 
258
281
  _NOTE: Post processing will not even *start* if the attachment is not valid
259
282
  according to the validations. Your callbacks and processors will *only* be
260
283
  called with valid attachments._
261
284
 
285
+ class Message < ActiveRecord::Base
286
+ has_attached_file :asset, styles: {thumb: "100x100#"}
287
+
288
+ before_post_process :skip_for_audio
289
+
290
+ def skip_for_audio
291
+ ! %w(audio/ogg application/ogg).include?(asset_content_type)
292
+ end
293
+ end
294
+
262
295
  URI Obfuscation
263
296
  ---------------
264
297
 
@@ -418,13 +451,13 @@ If you'd like to contribute a feature or bugfix: Thanks! To make sure your
418
451
  fix/feature has a high chance of being included, please read the following
419
452
  guidelines:
420
453
 
421
- 1. Ask on the mailing list[http://groups.google.com/group/paperclip-plugin], or
422
- post a new GitHub Issue[http://github.com/thoughtbot/paperclip/issues].
454
+ 1. Ask on the [mailing list](http://groups.google.com/group/paperclip-plugin), or
455
+ post a new [GitHub Issue](http://github.com/thoughtbot/paperclip/issues).
423
456
  2. Make sure there are tests! We will not accept any patch that is not tested.
424
457
  It's a rare time when explicit tests aren't needed. If you have questions
425
458
  about writing tests for paperclip, please ask the mailing list.
426
459
 
427
- Please see CONTRIBUTING.md for details.
460
+ Please see `CONTRIBUTING.md` for more details on contributing and running test.
428
461
 
429
462
  Credits
430
463
  -------
@@ -440,5 +473,5 @@ The names and logos for thoughtbot are trademarks of thoughtbot, inc.
440
473
  License
441
474
  -------
442
475
 
443
- Paperclip is Copyright © 2008-2011 thoughtbot. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
444
-
476
+ Paperclip is Copyright © 2008-2011 thoughtbot. It is free software, and may be
477
+ redistributed under the terms specified in the MIT-LICENSE file.
@@ -0,0 +1,4 @@
1
+ Running Tests
2
+ =============
3
+
4
+ Please see `CONTRIBUTING.md` in "Running Tests" section for more information.
data/Rakefile CHANGED
@@ -4,11 +4,16 @@ require 'rake/testtask'
4
4
  require 'cucumber/rake/task'
5
5
 
6
6
  desc 'Default: run unit tests.'
7
- task :default => [:clean, 'appraisal:install', :all]
7
+ task :default => [:clean, :all]
8
8
 
9
9
  desc 'Test the paperclip plugin under all supported Rails versions.'
10
10
  task :all do |t|
11
- exec('rake appraisal test cucumber')
11
+ if ENV['BUNDLE_GEMFILE']
12
+ exec('rake test cucumber')
13
+ else
14
+ Rake::Task["appraisal:install"].execute
15
+ exec('rake appraisal test cucumber')
16
+ end
12
17
  end
13
18
 
14
19
  desc 'Test the paperclip plugin.'
@@ -0,0 +1,14 @@
1
+ ##################################################
2
+ # NOTE FOR UPGRADING FROM PRE-3.0 VERSION #
3
+ ##################################################
4
+
5
+ Paperclip 3.0 introduces a non-backward compatible change in your attachment
6
+ path. This will help to prevent attachment name clashes when you have
7
+ multiple attachments with the same name. If you didn't alter your
8
+ attachment's path and are using Paperclip's default, you'll have to add
9
+ `:path` and `:url` to your `has_attached_file` definition. For example:
10
+
11
+ has_attached_file :avatar,
12
+ :path => ":rails_root/public/system/:attachment/:id/:style/:filename",
13
+ :url => "/system/:attachment/:id/:style/:filename"
14
+
@@ -11,7 +11,9 @@ Feature: Rails integration
11
11
  Scenario: Filesystem integration test
12
12
  Given I add this snippet to the User model:
13
13
  """
14
- has_attached_file :attachment
14
+ attr_accessible :name, :attachment
15
+ has_attached_file :attachment, :url => "/system/:attachment/:style/:filename",
16
+ :styles => { :square => "100x100#" }
15
17
  """
16
18
  And I start the rails application
17
19
  When I go to the new user page
@@ -19,16 +21,18 @@ Feature: Rails integration
19
21
  And I attach the file "test/fixtures/5k.png" to "Attachment"
20
22
  And I press "Submit"
21
23
  Then I should see "Name: something"
22
- And I should see an image with a path of "/system/attachments/1/original/5k.png"
23
- And the file at "/system/attachments/1/original/5k.png" should be the same as "test/fixtures/5k.png"
24
+ And I should see an image with a path of "/system/attachments/original/5k.png"
25
+ And the file at "/system/attachments/original/5k.png" should be the same as "test/fixtures/5k.png"
24
26
 
25
27
  Scenario: S3 Integration test
26
28
  Given I add this snippet to the User model:
27
29
  """
30
+ attr_accessible :name, :attachment
28
31
  has_attached_file :attachment,
29
32
  :storage => :s3,
30
- :path => "/:attachment/:id/:style/:filename",
31
- :s3_credentials => Rails.root.join("config/s3.yml")
33
+ :path => "/:attachment/:style/:filename",
34
+ :s3_credentials => Rails.root.join("config/s3.yml"),
35
+ :styles => { :square => "100x100#" }
32
36
  """
33
37
  And I write to "config/s3.yml" with:
34
38
  """
@@ -42,5 +46,5 @@ Feature: Rails integration
42
46
  And I attach the file "test/fixtures/5k.png" to "Attachment" on S3
43
47
  And I press "Submit"
44
48
  Then I should see "Name: something"
45
- And I should see an image with a path of "http://s3.amazonaws.com/paperclip/attachments/1/original/5k.png"
46
- And the file at "http://s3.amazonaws.com/paperclip/attachments/1/original/5k.png" should be uploaded to S3
49
+ And I should see an image with a path of "http://s3.amazonaws.com/paperclip/attachments/original/5k.png"
50
+ And the file at "http://s3.amazonaws.com/paperclip/attachments/original/5k.png" should be uploaded to S3