kt-paperclip 5.4.0 → 7.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +3 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- data/.github/ISSUE_TEMPLATE/custom.md +10 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.hound.yml +3 -1055
- data/.rubocop.yml +1061 -1
- data/.travis.yml +23 -4
- data/Appraisals +23 -0
- data/CONTRIBUTING.md +4 -5
- data/Gemfile +10 -7
- data/NEWS +52 -0
- data/README.md +58 -46
- data/Rakefile +29 -21
- data/UPGRADING +3 -3
- data/features/basic_integration.feature +4 -0
- data/features/migration.feature +10 -51
- data/features/step_definitions/attachment_steps.rb +23 -13
- data/features/step_definitions/html_steps.rb +5 -5
- data/features/step_definitions/rails_steps.rb +29 -9
- data/features/step_definitions/s3_steps.rb +3 -3
- data/features/step_definitions/web_steps.rb +5 -6
- data/features/support/env.rb +4 -4
- data/features/support/fakeweb.rb +3 -5
- data/features/support/file_helpers.rb +2 -2
- data/features/support/paths.rb +4 -4
- data/features/support/rails.rb +7 -7
- data/features/support/selectors.rb +1 -1
- data/gemfiles/4.2.gemfile +7 -4
- data/gemfiles/5.0.gemfile +7 -4
- data/gemfiles/5.1.gemfile +20 -0
- data/gemfiles/5.2.gemfile +20 -0
- data/gemfiles/6.0.gemfile +20 -0
- data/gemfiles/6.1.gemfile +21 -0
- data/gemfiles/7.0.gemfile +21 -0
- data/lib/generators/paperclip/paperclip_generator.rb +6 -8
- data/lib/paperclip/attachment.rb +103 -105
- data/lib/paperclip/attachment_registry.rb +2 -2
- data/lib/paperclip/content_type_detector.rb +10 -5
- data/lib/paperclip/file_command_content_type_detector.rb +1 -3
- data/lib/paperclip/filename_cleaner.rb +0 -1
- data/lib/paperclip/geometry.rb +18 -19
- data/lib/paperclip/geometry_detector_factory.rb +13 -16
- data/lib/paperclip/geometry_parser_factory.rb +5 -5
- data/lib/paperclip/glue.rb +3 -3
- data/lib/paperclip/has_attached_file.rb +5 -4
- data/lib/paperclip/helpers.rb +3 -3
- data/lib/paperclip/interpolations.rb +42 -38
- data/lib/paperclip/io_adapters/abstract_adapter.rb +16 -14
- data/lib/paperclip/io_adapters/attachment_adapter.rb +12 -6
- data/lib/paperclip/io_adapters/data_uri_adapter.rb +1 -1
- data/lib/paperclip/io_adapters/file_adapter.rb +1 -3
- data/lib/paperclip/io_adapters/http_url_proxy_adapter.rb +1 -1
- data/lib/paperclip/io_adapters/identity_adapter.rb +1 -2
- data/lib/paperclip/io_adapters/registry.rb +1 -1
- data/lib/paperclip/io_adapters/stringio_adapter.rb +1 -1
- data/lib/paperclip/io_adapters/uploaded_file_adapter.rb +6 -8
- data/lib/paperclip/io_adapters/uri_adapter.rb +21 -9
- data/lib/paperclip/logger.rb +1 -1
- data/lib/paperclip/matchers/have_attached_file_matcher.rb +4 -4
- data/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb +19 -18
- data/lib/paperclip/matchers/validate_attachment_presence_matcher.rb +4 -4
- data/lib/paperclip/matchers/validate_attachment_size_matcher.rb +11 -10
- data/lib/paperclip/matchers.rb +4 -4
- data/lib/paperclip/media_type_spoof_detector.rb +13 -13
- data/lib/paperclip/missing_attachment_styles.rb +11 -6
- data/lib/paperclip/processor.rb +13 -6
- data/lib/paperclip/processor_helpers.rb +3 -1
- data/lib/paperclip/rails_environment.rb +1 -5
- data/lib/paperclip/railtie.rb +5 -5
- data/lib/paperclip/schema.rb +16 -12
- data/lib/paperclip/storage/filesystem.rb +6 -8
- data/lib/paperclip/storage/fog.rb +36 -32
- data/lib/paperclip/storage/s3.rb +68 -76
- data/lib/paperclip/style.rb +3 -6
- data/lib/paperclip/tempfile.rb +4 -5
- data/lib/paperclip/tempfile_factory.rb +0 -1
- data/lib/paperclip/thumbnail.rb +11 -11
- data/lib/paperclip/url_generator.rb +5 -5
- data/lib/paperclip/validators/attachment_content_type_validator.rb +11 -4
- data/lib/paperclip/validators/attachment_file_name_validator.rb +14 -12
- data/lib/paperclip/validators/attachment_file_type_ignorance_validator.rb +1 -2
- data/lib/paperclip/validators/attachment_presence_validator.rb +3 -5
- data/lib/paperclip/validators/attachment_size_validator.rb +28 -11
- data/lib/paperclip/validators/media_type_spoof_detection_validator.rb +3 -1
- data/lib/paperclip/validators.rb +16 -17
- data/lib/paperclip/version.rb +1 -3
- data/lib/paperclip.rb +49 -48
- data/lib/tasks/paperclip.rake +23 -24
- data/paperclip.gemspec +29 -33
- data/shoulda_macros/paperclip.rb +16 -16
- data/spec/paperclip/attachment_definitions_spec.rb +5 -5
- data/spec/paperclip/attachment_processing_spec.rb +22 -23
- data/spec/paperclip/attachment_registry_spec.rb +15 -15
- data/spec/paperclip/attachment_spec.rb +238 -196
- data/spec/paperclip/content_type_detector_spec.rb +18 -12
- data/spec/paperclip/file_command_content_type_detector_spec.rb +10 -10
- data/spec/paperclip/filename_cleaner_spec.rb +3 -4
- data/spec/paperclip/geometry_detector_spec.rb +7 -8
- data/spec/paperclip/geometry_parser_spec.rb +31 -31
- data/spec/paperclip/geometry_spec.rb +24 -24
- data/spec/paperclip/glue_spec.rb +3 -5
- data/spec/paperclip/has_attached_file_spec.rb +46 -126
- data/spec/paperclip/integration_spec.rb +111 -77
- data/spec/paperclip/interpolations_spec.rb +101 -93
- data/spec/paperclip/io_adapters/abstract_adapter_spec.rb +41 -13
- data/spec/paperclip/io_adapters/attachment_adapter_spec.rb +8 -10
- data/spec/paperclip/io_adapters/data_uri_adapter_spec.rb +13 -14
- data/spec/paperclip/io_adapters/empty_string_adapter_spec.rb +4 -4
- data/spec/paperclip/io_adapters/file_adapter_spec.rb +12 -12
- data/spec/paperclip/io_adapters/http_url_proxy_adapter_spec.rb +58 -37
- data/spec/paperclip/io_adapters/identity_adapter_spec.rb +1 -1
- data/spec/paperclip/io_adapters/nil_adapter_spec.rb +2 -2
- data/spec/paperclip/io_adapters/registry_spec.rb +4 -4
- data/spec/paperclip/io_adapters/stringio_adapter_spec.rb +10 -10
- data/spec/paperclip/io_adapters/uploaded_file_adapter_spec.rb +6 -6
- data/spec/paperclip/io_adapters/uri_adapter_spec.rb +90 -31
- data/spec/paperclip/matchers/have_attached_file_matcher_spec.rb +3 -3
- data/spec/paperclip/matchers/validate_attachment_content_type_matcher_spec.rb +4 -5
- data/spec/paperclip/matchers/validate_attachment_presence_matcher_spec.rb +4 -4
- data/spec/paperclip/matchers/validate_attachment_size_matcher_spec.rb +4 -4
- data/spec/paperclip/media_type_spoof_detector_spec.rb +50 -24
- data/spec/paperclip/meta_class_spec.rb +3 -3
- data/spec/paperclip/paperclip_missing_attachment_styles_spec.rb +28 -24
- data/spec/paperclip/paperclip_spec.rb +15 -11
- data/spec/paperclip/plural_cache_spec.rb +8 -8
- data/spec/paperclip/processor_helpers_spec.rb +35 -35
- data/spec/paperclip/processor_spec.rb +8 -8
- data/spec/paperclip/rails_environment_spec.rb +7 -10
- data/spec/paperclip/rake_spec.rb +39 -39
- data/spec/paperclip/schema_spec.rb +57 -53
- data/spec/paperclip/storage/filesystem_spec.rb +29 -6
- data/spec/paperclip/storage/fog_spec.rb +122 -82
- data/spec/paperclip/storage/s3_live_spec.rb +22 -22
- data/spec/paperclip/storage/s3_spec.rb +649 -583
- data/spec/paperclip/style_spec.rb +67 -71
- data/spec/paperclip/tempfile_factory_spec.rb +5 -5
- data/spec/paperclip/thumbnail_spec.rb +68 -67
- data/spec/paperclip/url_generator_spec.rb +18 -19
- data/spec/paperclip/validators/attachment_content_type_validator_spec.rb +115 -27
- data/spec/paperclip/validators/attachment_file_name_validator_spec.rb +105 -16
- data/spec/paperclip/validators/attachment_presence_validator_spec.rb +5 -5
- data/spec/paperclip/validators/attachment_size_validator_spec.rb +111 -21
- data/spec/paperclip/validators/media_type_spoof_detection_validator_spec.rb +9 -13
- data/spec/paperclip/validators_spec.rb +61 -46
- data/spec/spec_helper.rb +21 -23
- data/spec/support/assertions.rb +8 -6
- data/spec/support/fake_model.rb +1 -2
- data/spec/support/fake_rails.rb +1 -1
- data/spec/support/fixtures/aws_s3.yml +13 -0
- data/spec/support/fixtures/sample.xlsm +0 -0
- data/spec/support/matchers/exist.rb +1 -1
- data/spec/support/matchers/have_column.rb +1 -1
- data/spec/support/mock_url_generator_builder.rb +2 -3
- data/spec/support/model_reconstruction.rb +16 -12
- data/spec/support/reporting.rb +1 -1
- data/spec/support/test_data.rb +2 -2
- metadata +58 -106
- data/spec/support/conditional_filter_helper.rb +0 -5
@@ -1,78 +1,77 @@
|
|
1
|
-
|
2
|
-
require 'spec_helper'
|
1
|
+
require "spec_helper"
|
3
2
|
|
4
|
-
describe
|
3
|
+
describe "Attachment Processing" do
|
5
4
|
before { rebuild_class }
|
6
5
|
|
7
|
-
context
|
8
|
-
it
|
6
|
+
context "using validates_attachment_content_type" do
|
7
|
+
it "processes attachments given a valid assignment" do
|
9
8
|
file = File.new(fixture_file("5k.png"))
|
10
9
|
Dummy.validates_attachment_content_type :avatar, content_type: "image/png"
|
11
10
|
instance = Dummy.new
|
12
11
|
attachment = instance.avatar
|
13
|
-
attachment.
|
12
|
+
expect(attachment).to receive(:post_process_styles)
|
14
13
|
|
15
14
|
attachment.assign(file)
|
16
15
|
end
|
17
16
|
|
18
|
-
it
|
17
|
+
it "does not process attachments given an invalid assignment with :not" do
|
19
18
|
file = File.new(fixture_file("5k.png"))
|
20
19
|
Dummy.validates_attachment_content_type :avatar, not: "image/png"
|
21
20
|
instance = Dummy.new
|
22
21
|
attachment = instance.avatar
|
23
|
-
attachment.
|
22
|
+
expect(attachment).not_to receive(:post_process_styles)
|
24
23
|
|
25
24
|
attachment.assign(file)
|
26
25
|
end
|
27
26
|
|
28
|
-
it
|
27
|
+
it "does not process attachments given an invalid assignment with :content_type" do
|
29
28
|
file = File.new(fixture_file("5k.png"))
|
30
29
|
Dummy.validates_attachment_content_type :avatar, content_type: "image/tiff"
|
31
30
|
instance = Dummy.new
|
32
31
|
attachment = instance.avatar
|
33
|
-
attachment.
|
32
|
+
expect(attachment).not_to receive(:post_process_styles)
|
34
33
|
|
35
34
|
attachment.assign(file)
|
36
35
|
end
|
37
36
|
|
38
|
-
it
|
37
|
+
it "allows what would be an invalid assignment when validation :if clause returns false" do
|
39
38
|
invalid_assignment = File.new(fixture_file("5k.png"))
|
40
|
-
Dummy.validates_attachment_content_type :avatar, content_type: "image/tiff", if: lambda{false}
|
39
|
+
Dummy.validates_attachment_content_type :avatar, content_type: "image/tiff", if: lambda { false }
|
41
40
|
instance = Dummy.new
|
42
41
|
attachment = instance.avatar
|
43
|
-
attachment.
|
42
|
+
expect(attachment).to receive(:post_process_styles)
|
44
43
|
|
45
44
|
attachment.assign(invalid_assignment)
|
46
45
|
end
|
47
46
|
end
|
48
47
|
|
49
|
-
context
|
50
|
-
it
|
48
|
+
context "using validates_attachment" do
|
49
|
+
it "processes attachments given a valid assignment" do
|
51
50
|
file = File.new(fixture_file("5k.png"))
|
52
|
-
Dummy.validates_attachment :avatar, content_type: {content_type: "image/png"}
|
51
|
+
Dummy.validates_attachment :avatar, content_type: { content_type: "image/png" }
|
53
52
|
instance = Dummy.new
|
54
53
|
attachment = instance.avatar
|
55
|
-
attachment.
|
54
|
+
expect(attachment).to receive(:post_process_styles)
|
56
55
|
|
57
56
|
attachment.assign(file)
|
58
57
|
end
|
59
58
|
|
60
|
-
it
|
59
|
+
it "does not process attachments given an invalid assignment with :not" do
|
61
60
|
file = File.new(fixture_file("5k.png"))
|
62
|
-
Dummy.validates_attachment :avatar, content_type: {not: "image/png"}
|
61
|
+
Dummy.validates_attachment :avatar, content_type: { not: "image/png" }
|
63
62
|
instance = Dummy.new
|
64
63
|
attachment = instance.avatar
|
65
|
-
attachment.
|
64
|
+
expect(attachment).not_to receive(:post_process_styles)
|
66
65
|
|
67
66
|
attachment.assign(file)
|
68
67
|
end
|
69
68
|
|
70
|
-
it
|
69
|
+
it "does not process attachments given an invalid assignment with :content_type" do
|
71
70
|
file = File.new(fixture_file("5k.png"))
|
72
|
-
Dummy.validates_attachment :avatar, content_type: {content_type: "image/tiff"}
|
71
|
+
Dummy.validates_attachment :avatar, content_type: { content_type: "image/tiff" }
|
73
72
|
instance = Dummy.new
|
74
73
|
attachment = instance.avatar
|
75
|
-
attachment.
|
74
|
+
expect(attachment).not_to receive(:post_process_styles)
|
76
75
|
|
77
76
|
attachment.assign(file)
|
78
77
|
end
|
@@ -1,19 +1,19 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe "Attachment Registry" do
|
4
4
|
before do
|
5
5
|
Paperclip::AttachmentRegistry.clear
|
6
6
|
end
|
7
7
|
|
8
|
-
context
|
9
|
-
it
|
8
|
+
context ".names_for" do
|
9
|
+
it "includes attachment names for the given class" do
|
10
10
|
foo = Class.new
|
11
11
|
Paperclip::AttachmentRegistry.register(foo, :avatar, {})
|
12
12
|
|
13
13
|
assert_equal [:avatar], Paperclip::AttachmentRegistry.names_for(foo)
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
16
|
+
it "does not include attachment names for other classes" do
|
17
17
|
foo = Class.new
|
18
18
|
bar = Class.new
|
19
19
|
Paperclip::AttachmentRegistry.register(foo, :avatar, {})
|
@@ -22,13 +22,13 @@ describe 'Attachment Registry' do
|
|
22
22
|
assert_equal [:lover], Paperclip::AttachmentRegistry.names_for(bar)
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
25
|
+
it "produces the empty array for a missing key" do
|
26
26
|
assert_empty Paperclip::AttachmentRegistry.names_for(Class.new)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
context
|
31
|
-
it
|
30
|
+
context ".each_definition" do
|
31
|
+
it "calls the block with the class, attachment name, and options" do
|
32
32
|
foo = Class.new
|
33
33
|
expected_accumulations = [
|
34
34
|
[foo, :avatar, { yo: "greeting" }],
|
@@ -47,8 +47,8 @@ describe 'Attachment Registry' do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
context
|
51
|
-
it
|
50
|
+
context ".definitions_for" do
|
51
|
+
it "produces the attachment name and options" do
|
52
52
|
expected_definitions = {
|
53
53
|
avatar: { yo: "greeting" },
|
54
54
|
greeter: { ciao: "greeting" }
|
@@ -70,7 +70,7 @@ describe 'Attachment Registry' do
|
|
70
70
|
assert_equal expected_definitions, definitions
|
71
71
|
end
|
72
72
|
|
73
|
-
it
|
73
|
+
it "produces defintions for subclasses" do
|
74
74
|
expected_definitions = { avatar: { yo: "greeting" } }
|
75
75
|
foo = Class.new
|
76
76
|
bar = Class.new(foo)
|
@@ -85,7 +85,7 @@ describe 'Attachment Registry' do
|
|
85
85
|
assert_equal expected_definitions, definitions
|
86
86
|
end
|
87
87
|
|
88
|
-
it
|
88
|
+
it "produces defintions for subclasses but deep merging them" do
|
89
89
|
foo_definitions = { avatar: { yo: "greeting" } }
|
90
90
|
bar_definitions = { avatar: { ciao: "greeting" } }
|
91
91
|
expected_definitions = {
|
@@ -112,7 +112,7 @@ describe 'Attachment Registry' do
|
|
112
112
|
assert_equal expected_definitions, definitions
|
113
113
|
end
|
114
114
|
|
115
|
-
it
|
115
|
+
it "allows subclasses to override attachment defitions" do
|
116
116
|
foo_definitions = { avatar: { yo: "greeting" } }
|
117
117
|
bar_definitions = { avatar: { yo: "hello" } }
|
118
118
|
|
@@ -141,8 +141,8 @@ describe 'Attachment Registry' do
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
-
context
|
145
|
-
it
|
144
|
+
context ".clear" do
|
145
|
+
it "removes all of the existing attachment definitions" do
|
146
146
|
foo = Class.new
|
147
147
|
Paperclip::AttachmentRegistry.register(
|
148
148
|
foo,
|