paperclip 4.3.7 → 5.0.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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +13 -9
  3. data/Appraisals +22 -6
  4. data/CONTRIBUTING.md +16 -5
  5. data/Gemfile +2 -8
  6. data/LICENSE +1 -1
  7. data/NEWS +39 -27
  8. data/README.md +123 -101
  9. data/UPGRADING +12 -9
  10. data/features/basic_integration.feature +1 -0
  11. data/features/migration.feature +0 -24
  12. data/features/step_definitions/rails_steps.rb +0 -6
  13. data/features/step_definitions/s3_steps.rb +2 -2
  14. data/gemfiles/{4.1.gemfile → 4.2.awsv2.0.gemfile} +4 -6
  15. data/gemfiles/4.2.awsv2.1.gemfile +17 -0
  16. data/gemfiles/{4.2.gemfile → 4.2.awsv2.gemfile} +1 -0
  17. data/gemfiles/5.0.awsv2.0.gemfile +17 -0
  18. data/gemfiles/5.0.awsv2.1.gemfile +17 -0
  19. data/gemfiles/{3.2.gemfile → 5.0.awsv2.gemfile} +2 -1
  20. data/lib/paperclip.rb +2 -3
  21. data/lib/paperclip/attachment.rb +12 -10
  22. data/lib/paperclip/attachment_registry.rb +2 -1
  23. data/lib/paperclip/callbacks.rb +8 -6
  24. data/lib/paperclip/content_type_detector.rb +3 -2
  25. data/lib/paperclip/errors.rb +3 -1
  26. data/lib/paperclip/glue.rb +1 -1
  27. data/lib/paperclip/has_attached_file.rb +7 -1
  28. data/lib/paperclip/helpers.rb +14 -10
  29. data/lib/paperclip/io_adapters/http_url_proxy_adapter.rb +1 -1
  30. data/lib/paperclip/io_adapters/uri_adapter.rb +12 -29
  31. data/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb +4 -4
  32. data/lib/paperclip/schema.rb +2 -8
  33. data/lib/paperclip/storage/fog.rb +9 -6
  34. data/lib/paperclip/storage/s3.rb +42 -40
  35. data/lib/paperclip/validators/attachment_size_validator.rb +1 -7
  36. data/lib/paperclip/version.rb +3 -1
  37. data/lib/tasks/paperclip.rake +1 -1
  38. data/paperclip.gemspec +11 -8
  39. data/spec/paperclip/attachment_processing_spec.rb +2 -4
  40. data/spec/paperclip/attachment_registry_spec.rb +28 -0
  41. data/spec/paperclip/attachment_spec.rb +33 -10
  42. data/spec/paperclip/has_attached_file_spec.rb +24 -8
  43. data/spec/paperclip/integration_spec.rb +4 -3
  44. data/spec/paperclip/io_adapters/http_url_proxy_adapter_spec.rb +17 -8
  45. data/spec/paperclip/io_adapters/uri_adapter_spec.rb +32 -30
  46. data/spec/paperclip/matchers/validate_attachment_content_type_matcher_spec.rb +10 -0
  47. data/spec/paperclip/paperclip_spec.rb +3 -33
  48. data/spec/paperclip/storage/fog_spec.rb +10 -0
  49. data/spec/paperclip/storage/s3_live_spec.rb +8 -4
  50. data/spec/paperclip/storage/s3_spec.rb +213 -156
  51. data/spec/paperclip/validators/attachment_size_validator_spec.rb +26 -20
  52. data/spec/paperclip/validators_spec.rb +3 -3
  53. data/spec/spec_helper.rb +3 -1
  54. data/spec/support/assertions.rb +7 -0
  55. data/spec/support/model_reconstruction.rb +9 -1
  56. data/spec/support/reporting.rb +11 -0
  57. metadata +44 -37
  58. data/cucumber/paperclip_steps.rb +0 -6
  59. data/lib/paperclip/deprecations.rb +0 -42
  60. data/lib/paperclip/locales/de.yml +0 -18
  61. data/lib/paperclip/locales/es.yml +0 -18
  62. data/lib/paperclip/locales/ja.yml +0 -18
  63. data/lib/paperclip/locales/pt-BR.yml +0 -18
  64. data/lib/paperclip/locales/zh-CN.yml +0 -18
  65. data/lib/paperclip/locales/zh-HK.yml +0 -18
  66. data/lib/paperclip/locales/zh-TW.yml +0 -18
  67. data/spec/paperclip/deprecations_spec.rb +0 -65
  68. data/spec/support/deprecations.rb +0 -9
  69. data/spec/support/rails_helpers.rb +0 -7
@@ -12,14 +12,6 @@ describe Paperclip::Validators::AttachmentSizeValidator do
12
12
  ))
13
13
  end
14
14
 
15
- def self.storage_units
16
- if defined?(ActiveSupport::NumberHelper) # Rails 4.0+
17
- { 5120 => '5 KB', 10240 => '10 KB' }
18
- else
19
- { 5120 => '5120 Bytes', 10240 => '10240 Bytes' }
20
- end
21
- end
22
-
23
15
  def self.should_allow_attachment_file_size(size)
24
16
  context "when the attachment size is #{size}" do
25
17
  it "adds error to dummy object" do
@@ -158,8 +150,10 @@ describe Paperclip::Validators::AttachmentSizeValidator do
158
150
  message: "is invalid. (Between %{min} and %{max} please.)"
159
151
  end
160
152
 
161
- should_not_allow_attachment_file_size 11.kilobytes,
162
- message: "is invalid. (Between #{storage_units[5120]} and #{storage_units[10240]} please.)"
153
+ should_not_allow_attachment_file_size(
154
+ 11.kilobytes,
155
+ message: "is invalid. (Between 5 KB and 10 KB please.)"
156
+ )
163
157
  end
164
158
 
165
159
  context "given :less_than and :greater_than" do
@@ -169,8 +163,10 @@ describe Paperclip::Validators::AttachmentSizeValidator do
169
163
  message: "is invalid. (Between %{min} and %{max} please.)"
170
164
  end
171
165
 
172
- should_not_allow_attachment_file_size 11.kilobytes,
173
- message: "is invalid. (Between #{storage_units[5120]} and #{storage_units[10240]} please.)"
166
+ should_not_allow_attachment_file_size(
167
+ 11.kilobytes,
168
+ message: "is invalid. (Between 5 KB and 10 KB please.)"
169
+ )
174
170
  end
175
171
  end
176
172
 
@@ -181,10 +177,15 @@ describe Paperclip::Validators::AttachmentSizeValidator do
181
177
  less_than: 10.kilobytes
182
178
  end
183
179
 
184
- should_not_allow_attachment_file_size 11.kilobytes,
185
- message: "must be less than #{storage_units[10240]}"
186
- should_not_allow_attachment_file_size 4.kilobytes,
187
- message: "must be greater than #{storage_units[5120]}"
180
+ should_not_allow_attachment_file_size(
181
+ 11.kilobytes,
182
+ message: "must be less than 10 KB"
183
+ )
184
+
185
+ should_not_allow_attachment_file_size(
186
+ 4.kilobytes,
187
+ message: "must be greater than 5 KB"
188
+ )
188
189
  end
189
190
 
190
191
  context "given a size range" do
@@ -192,10 +193,15 @@ describe Paperclip::Validators::AttachmentSizeValidator do
192
193
  build_validator in: (5.kilobytes..10.kilobytes)
193
194
  end
194
195
 
195
- should_not_allow_attachment_file_size 11.kilobytes,
196
- message: "must be in between #{storage_units[5120]} and #{storage_units[10240]}"
197
- should_not_allow_attachment_file_size 4.kilobytes,
198
- message: "must be in between #{storage_units[5120]} and #{storage_units[10240]}"
196
+ should_not_allow_attachment_file_size(
197
+ 11.kilobytes,
198
+ message: "must be in between 5 KB and 10 KB"
199
+ )
200
+
201
+ should_not_allow_attachment_file_size(
202
+ 4.kilobytes,
203
+ message: "must be in between 5 KB and 10 KB"
204
+ )
199
205
  end
200
206
  end
201
207
 
@@ -3,6 +3,7 @@ require 'spec_helper'
3
3
  describe Paperclip::Validators do
4
4
  context "using the helper" do
5
5
  before do
6
+ rebuild_class
6
7
  Dummy.validates_attachment :avatar, presence: true, content_type: { content_type: "image/jpeg" }, size: { in: 0..10240 }
7
8
  end
8
9
 
@@ -64,12 +65,11 @@ describe Paperclip::Validators do
64
65
  assert_raises(RuntimeError){ dummy.valid? }
65
66
  end
66
67
 
67
- it 'allows you to attach a file that does not violates these validations' do
68
+ it 'allows you to attach a file that does not violate these validations' do
68
69
  dummy = Dummy.new(avatar: File.new(fixture_file('rotated.jpg')))
69
- expect(dummy.errors.keys).to match_array []
70
+ expect(dummy.errors.full_messages).to be_empty
70
71
  assert dummy.valid?
71
72
  end
72
-
73
73
  end
74
74
 
75
75
  context "using the helper with a conditional" do
data/spec/spec_helper.rb CHANGED
@@ -7,6 +7,8 @@ require 'active_support/core_ext'
7
7
  require 'mocha/api'
8
8
  require 'bourne'
9
9
  require 'ostruct'
10
+ require 'pathname'
11
+ require 'activerecord-import'
10
12
 
11
13
  ROOT = Pathname(File.expand_path(File.join(File.dirname(__FILE__), '..')))
12
14
 
@@ -34,8 +36,8 @@ RSpec.configure do |config|
34
36
  config.include Assertions
35
37
  config.include ModelReconstruction
36
38
  config.include TestData
39
+ config.include Reporting
37
40
  config.extend VersionHelper
38
- config.extend RailsHelpers::ClassMethods
39
41
  config.mock_framework = :mocha
40
42
  config.before(:all) do
41
43
  rebuild_model
@@ -61,6 +61,13 @@ module Assertions
61
61
  end
62
62
  end
63
63
 
64
+ def assert_forbidden_response(url)
65
+ Net::HTTP.get_response(URI.parse(url)) do |response|
66
+ assert_equal "403", response.code,
67
+ "Expected HTTP response code 403, got #{response.code}"
68
+ end
69
+ end
70
+
64
71
  def assert_frame_dimensions(range, frames)
65
72
  frames.each_with_index do |frame, frame_index|
66
73
  frame.split('x').each_with_index do |dimension, dimension_index |
@@ -10,7 +10,15 @@ module ModelReconstruction
10
10
 
11
11
  klass.reset_column_information
12
12
  klass.connection_pool.clear_table_cache!(klass.table_name) if klass.connection_pool.respond_to?(:clear_table_cache!)
13
- klass.connection.schema_cache.clear_table_cache!(klass.table_name) if klass.connection.respond_to?(:schema_cache)
13
+
14
+ if klass.connection.respond_to?(:schema_cache)
15
+ if ActiveRecord::VERSION::STRING >= "5.0"
16
+ klass.connection.schema_cache.clear_data_source_cache!(klass.table_name)
17
+ else
18
+ klass.connection.schema_cache.clear_table_cache!(klass.table_name)
19
+ end
20
+ end
21
+
14
22
  klass
15
23
  end
16
24
 
@@ -0,0 +1,11 @@
1
+ module Reporting
2
+ def silence_stream(stream)
3
+ old_stream = stream.dup
4
+ stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
5
+ stream.sync = true
6
+ yield
7
+ ensure
8
+ stream.reopen(old_stream)
9
+ old_stream.close
10
+ end
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.7
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Yurek
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.2.0
19
+ version: 4.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 3.2.0
26
+ version: 4.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 3.2.0
33
+ version: 4.2.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 3.2.0
40
+ version: 4.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: cocaine
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -70,14 +70,14 @@ dependencies:
70
70
  name: mimemagic
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '='
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.3.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '='
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.3.0
83
83
  - !ruby/object:Gem::Dependency
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 3.2.0
89
+ version: 4.2.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 3.2.0
96
+ version: 4.2.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: shoulda
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -156,20 +156,20 @@ dependencies:
156
156
  requirements:
157
157
  - - ">="
158
158
  - !ruby/object:Gem::Version
159
- version: 1.5.7
160
- - - "<="
159
+ version: 2.0.34
160
+ - - "<"
161
161
  - !ruby/object:Gem::Version
162
- version: '2.0'
162
+ version: '3.0'
163
163
  type: :development
164
164
  prerelease: false
165
165
  version_requirements: !ruby/object:Gem::Requirement
166
166
  requirements:
167
167
  - - ">="
168
168
  - !ruby/object:Gem::Version
169
- version: 1.5.7
170
- - - "<="
169
+ version: 2.0.34
170
+ - - "<"
171
171
  - !ruby/object:Gem::Version
172
- version: '2.0'
172
+ version: '3.0'
173
173
  - !ruby/object:Gem::Dependency
174
174
  name: bourne
175
175
  requirement: !ruby/object:Gem::Requirement
@@ -344,14 +344,14 @@ dependencies:
344
344
  requirements:
345
345
  - - ">="
346
346
  - !ruby/object:Gem::Version
347
- version: 3.2.0
347
+ version: 4.2.0
348
348
  type: :development
349
349
  prerelease: false
350
350
  version_requirements: !ruby/object:Gem::Requirement
351
351
  requirements:
352
352
  - - ">="
353
353
  - !ruby/object:Gem::Version
354
- version: 3.2.0
354
+ version: 4.2.0
355
355
  - !ruby/object:Gem::Dependency
356
356
  name: generator_spec
357
357
  requirement: !ruby/object:Gem::Requirement
@@ -400,7 +400,6 @@ files:
400
400
  - RELEASING.md
401
401
  - Rakefile
402
402
  - UPGRADING
403
- - cucumber/paperclip_steps.rb
404
403
  - features/basic_integration.feature
405
404
  - features/migration.feature
406
405
  - features/rake_tasks.feature
@@ -418,9 +417,12 @@ files:
418
417
  - features/support/paths.rb
419
418
  - features/support/rails.rb
420
419
  - features/support/selectors.rb
421
- - gemfiles/3.2.gemfile
422
- - gemfiles/4.1.gemfile
423
- - gemfiles/4.2.gemfile
420
+ - gemfiles/4.2.awsv2.0.gemfile
421
+ - gemfiles/4.2.awsv2.1.gemfile
422
+ - gemfiles/4.2.awsv2.gemfile
423
+ - gemfiles/5.0.awsv2.0.gemfile
424
+ - gemfiles/5.0.awsv2.1.gemfile
425
+ - gemfiles/5.0.awsv2.gemfile
424
426
  - lib/generators/paperclip/USAGE
425
427
  - lib/generators/paperclip/paperclip_generator.rb
426
428
  - lib/generators/paperclip/templates/paperclip_migration.rb.erb
@@ -429,7 +431,6 @@ files:
429
431
  - lib/paperclip/attachment_registry.rb
430
432
  - lib/paperclip/callbacks.rb
431
433
  - lib/paperclip/content_type_detector.rb
432
- - lib/paperclip/deprecations.rb
433
434
  - lib/paperclip/errors.rb
434
435
  - lib/paperclip/file_command_content_type_detector.rb
435
436
  - lib/paperclip/filename_cleaner.rb
@@ -453,14 +454,7 @@ files:
453
454
  - lib/paperclip/io_adapters/stringio_adapter.rb
454
455
  - lib/paperclip/io_adapters/uploaded_file_adapter.rb
455
456
  - lib/paperclip/io_adapters/uri_adapter.rb
456
- - lib/paperclip/locales/de.yml
457
457
  - lib/paperclip/locales/en.yml
458
- - lib/paperclip/locales/es.yml
459
- - lib/paperclip/locales/ja.yml
460
- - lib/paperclip/locales/pt-BR.yml
461
- - lib/paperclip/locales/zh-CN.yml
462
- - lib/paperclip/locales/zh-HK.yml
463
- - lib/paperclip/locales/zh-TW.yml
464
458
  - lib/paperclip/logger.rb
465
459
  - lib/paperclip/matchers.rb
466
460
  - lib/paperclip/matchers/have_attached_file_matcher.rb
@@ -500,7 +494,6 @@ files:
500
494
  - spec/paperclip/attachment_registry_spec.rb
501
495
  - spec/paperclip/attachment_spec.rb
502
496
  - spec/paperclip/content_type_detector_spec.rb
503
- - spec/paperclip/deprecations_spec.rb
504
497
  - spec/paperclip/file_command_content_type_detector_spec.rb
505
498
  - spec/paperclip/filename_cleaner_spec.rb
506
499
  - spec/paperclip/geometry_detector_spec.rb
@@ -552,7 +545,6 @@ files:
552
545
  - spec/paperclip/validators_spec.rb
553
546
  - spec/spec_helper.rb
554
547
  - spec/support/assertions.rb
555
- - spec/support/deprecations.rb
556
548
  - spec/support/fake_model.rb
557
549
  - spec/support/fake_rails.rb
558
550
  - spec/support/fixtures/12k.png
@@ -579,14 +571,31 @@ files:
579
571
  - spec/support/mock_interpolator.rb
580
572
  - spec/support/mock_url_generator_builder.rb
581
573
  - spec/support/model_reconstruction.rb
582
- - spec/support/rails_helpers.rb
574
+ - spec/support/reporting.rb
583
575
  - spec/support/test_data.rb
584
576
  - spec/support/version_helper.rb
585
577
  homepage: https://github.com/thoughtbot/paperclip
586
578
  licenses:
587
579
  - MIT
588
580
  metadata: {}
589
- post_install_message:
581
+ post_install_message: |
582
+ ##################################################
583
+ # NOTE FOR UPGRADING FROM 4.3.0 OR EARLIER #
584
+ ##################################################
585
+
586
+ Paperclip is now compatible with aws-sdk >= 2.0.0.
587
+
588
+ If you are using S3 storage, aws-sdk >= 2.0.0 requires you to make a few small
589
+ changes:
590
+
591
+ * You must set the `s3_region`
592
+ * If you are explicitly setting permissions anywhere, such as in an initializer,
593
+ note that the format of the permissions changed from using an underscore to
594
+ using a hyphen. For example, `:public_read` needs to be changed to
595
+ `public-read`.
596
+
597
+ For a walkthrough of upgrading from 4 to 5 and aws-sdk >= 2.0 you can watch
598
+ http://rubythursday.com/episodes/ruby-snack-27-upgrade-paperclip-and-aws-sdk-in-prep-for-rails-5
590
599
  rdoc_options: []
591
600
  require_paths:
592
601
  - lib
@@ -594,7 +603,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
594
603
  requirements:
595
604
  - - ">="
596
605
  - !ruby/object:Gem::Version
597
- version: 1.9.2
606
+ version: 2.1.0
598
607
  required_rubygems_version: !ruby/object:Gem::Requirement
599
608
  requirements:
600
609
  - - ">="
@@ -631,7 +640,6 @@ test_files:
631
640
  - spec/paperclip/attachment_registry_spec.rb
632
641
  - spec/paperclip/attachment_spec.rb
633
642
  - spec/paperclip/content_type_detector_spec.rb
634
- - spec/paperclip/deprecations_spec.rb
635
643
  - spec/paperclip/file_command_content_type_detector_spec.rb
636
644
  - spec/paperclip/filename_cleaner_spec.rb
637
645
  - spec/paperclip/geometry_detector_spec.rb
@@ -683,7 +691,6 @@ test_files:
683
691
  - spec/paperclip/validators_spec.rb
684
692
  - spec/spec_helper.rb
685
693
  - spec/support/assertions.rb
686
- - spec/support/deprecations.rb
687
694
  - spec/support/fake_model.rb
688
695
  - spec/support/fake_rails.rb
689
696
  - spec/support/fixtures/12k.png
@@ -710,6 +717,6 @@ test_files:
710
717
  - spec/support/mock_interpolator.rb
711
718
  - spec/support/mock_url_generator_builder.rb
712
719
  - spec/support/model_reconstruction.rb
713
- - spec/support/rails_helpers.rb
720
+ - spec/support/reporting.rb
714
721
  - spec/support/test_data.rb
715
722
  - spec/support/version_helper.rb
@@ -1,6 +0,0 @@
1
- When /^I attach an? "([^\"]*)" "([^\"]*)" file to an? "([^\"]*)" on S3$/ do |attachment, extension, model|
2
- stub_paperclip_s3(model, attachment, extension)
3
- attach_file attachment,
4
- "features/support/paperclip/#{model.gsub(" ", "_").underscore}/#{attachment}.#{extension}"
5
- end
6
-
@@ -1,42 +0,0 @@
1
- require "active_support/deprecation"
2
-
3
- module Paperclip
4
- class Deprecations
5
- class << self
6
- def check
7
- warn_aws_sdk_v1 if aws_sdk_v1?
8
- warn_outdated_rails if active_model_version < "4.2"
9
- end
10
-
11
- private
12
-
13
- def active_model_version
14
- ::ActiveModel::VERSION::STRING
15
- end
16
-
17
- def aws_sdk_v1?
18
- defined?(::AWS) && aws_sdk_version < "2"
19
- end
20
-
21
- def warn_aws_sdk_v1
22
- warn "[paperclip] [deprecation] AWS SDK v1 has been deprecated in " \
23
- "paperclip 5. Please consider upgrading to AWS 2 before " \
24
- "upgrading paperclip."
25
- end
26
-
27
- def warn_outdated_rails
28
- warn "[paperclip] [deprecation] Rails 3.2 and 4.1 are unsupported as " \
29
- "of Rails 5 release. Please upgrade to Rails 4.2 before " \
30
- "upgrading paperclip."
31
- end
32
-
33
- def aws_sdk_version
34
- ::AWS::VERSION
35
- end
36
-
37
- def warn(message)
38
- ActiveSupport::Deprecation.warn(message)
39
- end
40
- end
41
- end
42
- end