kt-paperclip 7.0.0 → 7.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.hound.yml +3 -1057
- data/.rubocop.yml +1059 -1
- data/CONTRIBUTING.md +4 -5
- data/Gemfile +2 -1
- data/NEWS +11 -0
- data/README.md +3 -3
- data/gemfiles/7.0.gemfile +21 -0
- data/lib/paperclip/attachment.rb +1 -1
- data/lib/paperclip/content_type_detector.rb +8 -3
- data/lib/paperclip/geometry_detector_factory.rb +1 -1
- data/lib/paperclip/glue.rb +3 -2
- data/lib/paperclip/interpolations.rb +6 -2
- data/lib/paperclip/locales/gd.yml +20 -0
- data/lib/paperclip/media_type_spoof_detector.rb +4 -1
- data/lib/paperclip/schema.rb +2 -2
- data/lib/paperclip/storage/filesystem.rb +1 -1
- data/lib/paperclip/storage/fog.rb +1 -1
- data/lib/paperclip/storage/s3.rb +18 -4
- data/lib/paperclip/validators/attachment_file_name_validator.rb +1 -1
- data/lib/paperclip/validators/attachment_size_validator.rb +2 -1
- data/lib/paperclip/version.rb +1 -1
- data/paperclip.gemspec +1 -1
- data/spec/paperclip/attachment_spec.rb +6 -6
- data/spec/paperclip/content_type_detector_spec.rb +7 -0
- data/spec/paperclip/geometry_detector_spec.rb +9 -0
- data/spec/paperclip/geometry_spec.rb +16 -4
- data/spec/paperclip/glue_spec.rb +21 -0
- data/spec/paperclip/io_adapters/uri_adapter_spec.rb +1 -1
- data/spec/paperclip/media_type_spoof_detector_spec.rb +10 -4
- data/spec/paperclip/paperclip_missing_attachment_styles_spec.rb +1 -1
- data/spec/paperclip/paperclip_spec.rb +1 -1
- data/spec/paperclip/schema_spec.rb +18 -18
- data/spec/paperclip/storage/filesystem_spec.rb +23 -0
- data/spec/paperclip/storage/fog_spec.rb +46 -0
- data/spec/paperclip/storage/s3_spec.rb +179 -47
- data/spec/paperclip/validators_spec.rb +21 -6
- data/spec/spec_helper.rb +1 -0
- data/spec/support/fixtures/sample.xlsm +0 -0
- data/spec/support/model_reconstruction.rb +3 -3
- metadata +123 -8
@@ -1,6 +1,11 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Paperclip::Validators do
|
4
|
+
# required to support a range of rubies
|
5
|
+
def error_attribute_names(error)
|
6
|
+
error.try(:attribute_names) || error.keys
|
7
|
+
end
|
8
|
+
|
4
9
|
context "using the helper" do
|
5
10
|
before do
|
6
11
|
rebuild_class
|
@@ -22,7 +27,9 @@ describe Paperclip::Validators do
|
|
22
27
|
it "prevents you from attaching a file that violates that validation" do
|
23
28
|
Dummy.class_eval { validate(:name) { raise "DO NOT RUN THIS" } }
|
24
29
|
dummy = Dummy.new(avatar: File.new(fixture_file("12k.png")))
|
25
|
-
expect(dummy.errors
|
30
|
+
expect(error_attribute_names(dummy.errors)).to match_array(
|
31
|
+
%i[avatar_content_type avatar avatar_file_size]
|
32
|
+
)
|
26
33
|
assert_raises(RuntimeError) { dummy.valid? }
|
27
34
|
end
|
28
35
|
end
|
@@ -47,21 +54,27 @@ describe Paperclip::Validators do
|
|
47
54
|
it "prevents you from attaching a file that violates all of these validations" do
|
48
55
|
Dummy.class_eval { validate(:name) { raise "DO NOT RUN THIS" } }
|
49
56
|
dummy = Dummy.new(avatar: File.new(fixture_file("spaced file.png")))
|
50
|
-
expect(dummy.errors
|
57
|
+
expect(error_attribute_names(dummy.errors)).to match_array(
|
58
|
+
%i[avatar avatar_file_name]
|
59
|
+
)
|
51
60
|
assert_raises(RuntimeError) { dummy.valid? }
|
52
61
|
end
|
53
62
|
|
54
63
|
it "prevents you from attaching a file that violates only first of these validations" do
|
55
64
|
Dummy.class_eval { validate(:name) { raise "DO NOT RUN THIS" } }
|
56
65
|
dummy = Dummy.new(avatar: File.new(fixture_file("5k.png")))
|
57
|
-
expect(dummy.errors
|
66
|
+
expect(error_attribute_names(dummy.errors)).to match_array(
|
67
|
+
%i[avatar avatar_file_name]
|
68
|
+
)
|
58
69
|
assert_raises(RuntimeError) { dummy.valid? }
|
59
70
|
end
|
60
71
|
|
61
72
|
it "prevents you from attaching a file that violates only second of these validations" do
|
62
73
|
Dummy.class_eval { validate(:name) { raise "DO NOT RUN THIS" } }
|
63
74
|
dummy = Dummy.new(avatar: File.new(fixture_file("spaced file.jpg")))
|
64
|
-
expect(dummy.errors
|
75
|
+
expect(error_attribute_names(dummy.errors)).to match_array(
|
76
|
+
%i[avatar avatar_file_name]
|
77
|
+
)
|
65
78
|
assert_raises(RuntimeError) { dummy.valid? }
|
66
79
|
end
|
67
80
|
|
@@ -88,7 +101,9 @@ describe Paperclip::Validators do
|
|
88
101
|
end
|
89
102
|
end
|
90
103
|
dummy = Dummy.new(avatar: File.new(fixture_file("12k.png")))
|
91
|
-
expect(dummy.errors
|
104
|
+
expect(error_attribute_names(dummy.errors)).to match_array(
|
105
|
+
%i[avatar_content_type avatar avatar_file_size]
|
106
|
+
)
|
92
107
|
end
|
93
108
|
|
94
109
|
it "does not validate attachment if title is not present" do
|
@@ -98,7 +113,7 @@ describe Paperclip::Validators do
|
|
98
113
|
end
|
99
114
|
end
|
100
115
|
dummy = Dummy.new(avatar: File.new(fixture_file("12k.png")))
|
101
|
-
assert_equal [], dummy.errors
|
116
|
+
assert_equal [], error_attribute_names(dummy.errors)
|
102
117
|
end
|
103
118
|
end
|
104
119
|
|
data/spec/spec_helper.rb
CHANGED
@@ -21,6 +21,7 @@ FIXTURES_DIR = File.join(File.dirname(__FILE__), "fixtures")
|
|
21
21
|
config = YAML::safe_load(IO.read(File.dirname(__FILE__) + "/database.yml"))
|
22
22
|
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
|
23
23
|
ActiveRecord::Base.establish_connection(config["test"])
|
24
|
+
ActiveRecord::Migration.verbose = false
|
24
25
|
if ActiveRecord::VERSION::STRING >= "4.2" &&
|
25
26
|
ActiveRecord::VERSION::STRING < "5.0"
|
26
27
|
ActiveRecord::Base.raise_in_transactional_callbacks = true
|
Binary file
|
@@ -28,15 +28,15 @@ module ModelReconstruction
|
|
28
28
|
|
29
29
|
def reset_table(_table_name, &block)
|
30
30
|
block ||= lambda { |_table| true }
|
31
|
-
ActiveRecord::
|
31
|
+
ActiveRecord::Migration.create_table :dummies, **{ force: true }, &block
|
32
32
|
end
|
33
33
|
|
34
34
|
def modify_table(&block)
|
35
|
-
ActiveRecord::
|
35
|
+
ActiveRecord::Migration.change_table :dummies, &block
|
36
36
|
end
|
37
37
|
|
38
38
|
def rebuild_model(options = {})
|
39
|
-
ActiveRecord::
|
39
|
+
ActiveRecord::Migration.create_table :dummies, force: true do |table|
|
40
40
|
table.column :title, :string
|
41
41
|
table.column :other, :string
|
42
42
|
table.column :avatar_file_name, :string
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kt-paperclip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Surendra Singhi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -70,16 +70,22 @@ dependencies:
|
|
70
70
|
name: terrapin
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 0.6.0
|
76
|
+
- - "<"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '2.0'
|
76
79
|
type: :runtime
|
77
80
|
prerelease: false
|
78
81
|
version_requirements: !ruby/object:Gem::Requirement
|
79
82
|
requirements:
|
80
|
-
- - "
|
83
|
+
- - ">="
|
81
84
|
- !ruby/object:Gem::Version
|
82
85
|
version: 0.6.0
|
86
|
+
- - "<"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '2.0'
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
90
|
name: activerecord
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -394,6 +400,7 @@ files:
|
|
394
400
|
- gemfiles/5.2.gemfile
|
395
401
|
- gemfiles/6.0.gemfile
|
396
402
|
- gemfiles/6.1.gemfile
|
403
|
+
- gemfiles/7.0.gemfile
|
397
404
|
- lib/generators/paperclip/USAGE
|
398
405
|
- lib/generators/paperclip/paperclip_generator.rb
|
399
406
|
- lib/generators/paperclip/templates/paperclip_migration.rb.erb
|
@@ -427,6 +434,7 @@ files:
|
|
427
434
|
- lib/paperclip/io_adapters/uploaded_file_adapter.rb
|
428
435
|
- lib/paperclip/io_adapters/uri_adapter.rb
|
429
436
|
- lib/paperclip/locales/en.yml
|
437
|
+
- lib/paperclip/locales/gd.yml
|
430
438
|
- lib/paperclip/logger.rb
|
431
439
|
- lib/paperclip/matchers.rb
|
432
440
|
- lib/paperclip/matchers/have_attached_file_matcher.rb
|
@@ -533,6 +541,7 @@ files:
|
|
533
541
|
- spec/support/fixtures/fog.yml
|
534
542
|
- spec/support/fixtures/rotated.jpg
|
535
543
|
- spec/support/fixtures/s3.yml
|
544
|
+
- spec/support/fixtures/sample.xlsm
|
536
545
|
- spec/support/fixtures/spaced file.jpg
|
537
546
|
- spec/support/fixtures/spaced file.png
|
538
547
|
- spec/support/fixtures/text.txt
|
@@ -585,8 +594,114 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
585
594
|
version: '0'
|
586
595
|
requirements:
|
587
596
|
- ImageMagick
|
588
|
-
rubygems_version: 3.
|
589
|
-
signing_key:
|
597
|
+
rubygems_version: 3.1.6
|
598
|
+
signing_key:
|
590
599
|
specification_version: 4
|
591
600
|
summary: File attachments as attributes for ActiveRecord
|
592
|
-
test_files:
|
601
|
+
test_files:
|
602
|
+
- features/basic_integration.feature
|
603
|
+
- features/migration.feature
|
604
|
+
- features/rake_tasks.feature
|
605
|
+
- features/step_definitions/attachment_steps.rb
|
606
|
+
- features/step_definitions/html_steps.rb
|
607
|
+
- features/step_definitions/rails_steps.rb
|
608
|
+
- features/step_definitions/s3_steps.rb
|
609
|
+
- features/step_definitions/web_steps.rb
|
610
|
+
- features/support/env.rb
|
611
|
+
- features/support/fakeweb.rb
|
612
|
+
- features/support/file_helpers.rb
|
613
|
+
- features/support/fixtures/boot_config.txt
|
614
|
+
- features/support/fixtures/gemfile.txt
|
615
|
+
- features/support/fixtures/preinitializer.txt
|
616
|
+
- features/support/paths.rb
|
617
|
+
- features/support/rails.rb
|
618
|
+
- features/support/selectors.rb
|
619
|
+
- spec/database.yml
|
620
|
+
- spec/paperclip/attachment_definitions_spec.rb
|
621
|
+
- spec/paperclip/attachment_processing_spec.rb
|
622
|
+
- spec/paperclip/attachment_registry_spec.rb
|
623
|
+
- spec/paperclip/attachment_spec.rb
|
624
|
+
- spec/paperclip/content_type_detector_spec.rb
|
625
|
+
- spec/paperclip/file_command_content_type_detector_spec.rb
|
626
|
+
- spec/paperclip/filename_cleaner_spec.rb
|
627
|
+
- spec/paperclip/geometry_detector_spec.rb
|
628
|
+
- spec/paperclip/geometry_parser_spec.rb
|
629
|
+
- spec/paperclip/geometry_spec.rb
|
630
|
+
- spec/paperclip/glue_spec.rb
|
631
|
+
- spec/paperclip/has_attached_file_spec.rb
|
632
|
+
- spec/paperclip/integration_spec.rb
|
633
|
+
- spec/paperclip/interpolations_spec.rb
|
634
|
+
- spec/paperclip/io_adapters/abstract_adapter_spec.rb
|
635
|
+
- spec/paperclip/io_adapters/attachment_adapter_spec.rb
|
636
|
+
- spec/paperclip/io_adapters/data_uri_adapter_spec.rb
|
637
|
+
- spec/paperclip/io_adapters/empty_string_adapter_spec.rb
|
638
|
+
- spec/paperclip/io_adapters/file_adapter_spec.rb
|
639
|
+
- spec/paperclip/io_adapters/http_url_proxy_adapter_spec.rb
|
640
|
+
- spec/paperclip/io_adapters/identity_adapter_spec.rb
|
641
|
+
- spec/paperclip/io_adapters/nil_adapter_spec.rb
|
642
|
+
- spec/paperclip/io_adapters/registry_spec.rb
|
643
|
+
- spec/paperclip/io_adapters/stringio_adapter_spec.rb
|
644
|
+
- spec/paperclip/io_adapters/uploaded_file_adapter_spec.rb
|
645
|
+
- spec/paperclip/io_adapters/uri_adapter_spec.rb
|
646
|
+
- spec/paperclip/matchers/have_attached_file_matcher_spec.rb
|
647
|
+
- spec/paperclip/matchers/validate_attachment_content_type_matcher_spec.rb
|
648
|
+
- spec/paperclip/matchers/validate_attachment_presence_matcher_spec.rb
|
649
|
+
- spec/paperclip/matchers/validate_attachment_size_matcher_spec.rb
|
650
|
+
- spec/paperclip/media_type_spoof_detector_spec.rb
|
651
|
+
- spec/paperclip/meta_class_spec.rb
|
652
|
+
- spec/paperclip/paperclip_missing_attachment_styles_spec.rb
|
653
|
+
- spec/paperclip/paperclip_spec.rb
|
654
|
+
- spec/paperclip/plural_cache_spec.rb
|
655
|
+
- spec/paperclip/processor_helpers_spec.rb
|
656
|
+
- spec/paperclip/processor_spec.rb
|
657
|
+
- spec/paperclip/rails_environment_spec.rb
|
658
|
+
- spec/paperclip/rake_spec.rb
|
659
|
+
- spec/paperclip/schema_spec.rb
|
660
|
+
- spec/paperclip/storage/filesystem_spec.rb
|
661
|
+
- spec/paperclip/storage/fog_spec.rb
|
662
|
+
- spec/paperclip/storage/s3_live_spec.rb
|
663
|
+
- spec/paperclip/storage/s3_spec.rb
|
664
|
+
- spec/paperclip/style_spec.rb
|
665
|
+
- spec/paperclip/tempfile_factory_spec.rb
|
666
|
+
- spec/paperclip/tempfile_spec.rb
|
667
|
+
- spec/paperclip/thumbnail_spec.rb
|
668
|
+
- spec/paperclip/url_generator_spec.rb
|
669
|
+
- spec/paperclip/validators/attachment_content_type_validator_spec.rb
|
670
|
+
- spec/paperclip/validators/attachment_file_name_validator_spec.rb
|
671
|
+
- spec/paperclip/validators/attachment_presence_validator_spec.rb
|
672
|
+
- spec/paperclip/validators/attachment_size_validator_spec.rb
|
673
|
+
- spec/paperclip/validators/media_type_spoof_detection_validator_spec.rb
|
674
|
+
- spec/paperclip/validators_spec.rb
|
675
|
+
- spec/spec_helper.rb
|
676
|
+
- spec/support/assertions.rb
|
677
|
+
- spec/support/fake_model.rb
|
678
|
+
- spec/support/fake_rails.rb
|
679
|
+
- spec/support/fixtures/12k.png
|
680
|
+
- spec/support/fixtures/50x50.png
|
681
|
+
- spec/support/fixtures/5k.png
|
682
|
+
- spec/support/fixtures/animated
|
683
|
+
- spec/support/fixtures/animated.gif
|
684
|
+
- spec/support/fixtures/animated.unknown
|
685
|
+
- spec/support/fixtures/aws_s3.yml
|
686
|
+
- spec/support/fixtures/bad.png
|
687
|
+
- spec/support/fixtures/empty.html
|
688
|
+
- spec/support/fixtures/empty.xlsx
|
689
|
+
- spec/support/fixtures/fog.yml
|
690
|
+
- spec/support/fixtures/rotated.jpg
|
691
|
+
- spec/support/fixtures/s3.yml
|
692
|
+
- spec/support/fixtures/sample.xlsm
|
693
|
+
- spec/support/fixtures/spaced file.jpg
|
694
|
+
- spec/support/fixtures/spaced file.png
|
695
|
+
- spec/support/fixtures/text.txt
|
696
|
+
- spec/support/fixtures/twopage.pdf
|
697
|
+
- spec/support/fixtures/uppercase.PNG
|
698
|
+
- spec/support/matchers/accept.rb
|
699
|
+
- spec/support/matchers/exist.rb
|
700
|
+
- spec/support/matchers/have_column.rb
|
701
|
+
- spec/support/mock_attachment.rb
|
702
|
+
- spec/support/mock_interpolator.rb
|
703
|
+
- spec/support/mock_url_generator_builder.rb
|
704
|
+
- spec/support/model_reconstruction.rb
|
705
|
+
- spec/support/reporting.rb
|
706
|
+
- spec/support/test_data.rb
|
707
|
+
- spec/support/version_helper.rb
|