kt-paperclip 6.4.0 → 7.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -1
  3. data/.hound.yml +3 -1057
  4. data/.rubocop.yml +1059 -1
  5. data/.travis.yml +5 -5
  6. data/Appraisals +6 -0
  7. data/CONTRIBUTING.md +4 -5
  8. data/Gemfile +2 -2
  9. data/NEWS +32 -0
  10. data/README.md +8 -7
  11. data/features/step_definitions/attachment_steps.rb +11 -1
  12. data/gemfiles/4.2.gemfile +1 -1
  13. data/gemfiles/5.0.gemfile +1 -1
  14. data/gemfiles/5.1.gemfile +1 -1
  15. data/gemfiles/5.2.gemfile +1 -1
  16. data/gemfiles/6.0.gemfile +1 -1
  17. data/gemfiles/6.1.gemfile +21 -0
  18. data/gemfiles/7.0.gemfile +21 -0
  19. data/lib/paperclip/attachment.rb +1 -1
  20. data/lib/paperclip/content_type_detector.rb +10 -5
  21. data/lib/paperclip/geometry_detector_factory.rb +1 -1
  22. data/lib/paperclip/glue.rb +3 -2
  23. data/lib/paperclip/interpolations.rb +6 -2
  24. data/lib/paperclip/io_adapters/uri_adapter.rb +13 -3
  25. data/lib/paperclip/locales/gd.yml +20 -0
  26. data/lib/paperclip/media_type_spoof_detector.rb +4 -1
  27. data/lib/paperclip/schema.rb +1 -1
  28. data/lib/paperclip/storage/filesystem.rb +1 -1
  29. data/lib/paperclip/storage/fog.rb +1 -1
  30. data/lib/paperclip/storage/s3.rb +18 -4
  31. data/lib/paperclip/validators/attachment_content_type_validator.rb +1 -1
  32. data/lib/paperclip/validators/attachment_file_name_validator.rb +2 -2
  33. data/lib/paperclip/validators/attachment_presence_validator.rb +1 -1
  34. data/lib/paperclip/validators/attachment_size_validator.rb +3 -2
  35. data/lib/paperclip/version.rb +1 -1
  36. data/lib/paperclip.rb +1 -2
  37. data/paperclip.gemspec +3 -3
  38. data/spec/paperclip/content_type_detector_spec.rb +7 -0
  39. data/spec/paperclip/geometry_detector_spec.rb +9 -0
  40. data/spec/paperclip/geometry_spec.rb +16 -4
  41. data/spec/paperclip/glue_spec.rb +21 -0
  42. data/spec/paperclip/io_adapters/abstract_adapter_spec.rb +1 -1
  43. data/spec/paperclip/io_adapters/file_adapter_spec.rb +1 -1
  44. data/spec/paperclip/io_adapters/uri_adapter_spec.rb +13 -3
  45. data/spec/paperclip/media_type_spoof_detector_spec.rb +10 -4
  46. data/spec/paperclip/paperclip_spec.rb +1 -1
  47. data/spec/paperclip/storage/filesystem_spec.rb +23 -0
  48. data/spec/paperclip/storage/fog_spec.rb +46 -0
  49. data/spec/paperclip/storage/s3_spec.rb +179 -47
  50. data/spec/paperclip/validators_spec.rb +21 -6
  51. data/spec/support/fixtures/sample.xlsm +0 -0
  52. metadata +121 -11
@@ -147,23 +147,35 @@ describe Paperclip::Geometry do
147
147
 
148
148
  it "does not generate from a bad file" do
149
149
  file = "/home/This File Does Not Exist.omg"
150
- expect { @geo = Paperclip::Geometry.from_file(file) }.to raise_error(Paperclip::Errors::NotIdentifiedByImageMagickError)
150
+ expect do
151
+ @geo = Paperclip::Geometry.from_file(file)
152
+ end.to raise_error(Paperclip::Errors::NotIdentifiedByImageMagickError,
153
+ "Could not identify image size")
151
154
  end
152
155
 
153
156
  it "does not generate from a blank filename" do
154
157
  file = ""
155
- expect { @geo = Paperclip::Geometry.from_file(file) }.to raise_error(Paperclip::Errors::NotIdentifiedByImageMagickError)
158
+ expect do
159
+ @geo = Paperclip::Geometry.from_file(file)
160
+ end.to raise_error(Paperclip::Errors::NotIdentifiedByImageMagickError,
161
+ "Cannot find the geometry of a file with a blank name")
156
162
  end
157
163
 
158
164
  it "does not generate from a nil file" do
159
165
  file = nil
160
- expect { @geo = Paperclip::Geometry.from_file(file) }.to raise_error(Paperclip::Errors::NotIdentifiedByImageMagickError)
166
+ expect do
167
+ @geo = Paperclip::Geometry.from_file(file)
168
+ end.to raise_error(Paperclip::Errors::NotIdentifiedByImageMagickError,
169
+ "Cannot find the geometry of a file with a blank name")
161
170
  end
162
171
 
163
172
  it "does not generate from a file with no path" do
164
173
  file = double("file", path: "")
165
174
  allow(file).to receive(:respond_to?).with(:path).and_return(true)
166
- expect { @geo = Paperclip::Geometry.from_file(file) }.to raise_error(Paperclip::Errors::NotIdentifiedByImageMagickError)
175
+ expect do
176
+ @geo = Paperclip::Geometry.from_file(file)
177
+ end.to raise_error(Paperclip::Errors::NotIdentifiedByImageMagickError,
178
+ "Cannot find the geometry of a file with a blank name")
167
179
  end
168
180
 
169
181
  it "lets us know when a command isn't found versus a processing error" do
@@ -39,4 +39,25 @@ describe Paperclip::Glue do
39
39
  Object.send :remove_const, "NonActiveRecordModel"
40
40
  end
41
41
  end
42
+
43
+ describe "when included" do
44
+ it "does not mutate I18n.load_path more than once" do
45
+ before_load_path = I18n.load_path
46
+ I18n.load_path = []
47
+
48
+ # expect twice because the load_path is reset after creating the classes
49
+ expect(I18n.config).to receive(:load_path=).and_call_original.twice
50
+
51
+ FirstModel = Class.new
52
+ FirstModel.include Paperclip::Glue
53
+
54
+ SecondModel = Class.new
55
+ SecondModel.include Paperclip::Glue
56
+
57
+ ThirdModel = Class.new
58
+ ThirdModel.include Paperclip::Glue
59
+
60
+ I18n.load_path = before_load_path
61
+ end
62
+ end
42
63
  end
@@ -15,7 +15,7 @@ describe Paperclip::AbstractAdapter do
15
15
  before do
16
16
  allow(subject).to receive(:path).and_return("image.png")
17
17
  allow(Paperclip).to receive(:run).and_return("image/png\n")
18
- allow_any_instance_of(Paperclip::ContentTypeDetector).to receive(:type_from_mime_magic).and_return("image/png")
18
+ allow_any_instance_of(Paperclip::ContentTypeDetector).to receive(:type_from_marcel).and_return("image/png")
19
19
  end
20
20
 
21
21
  it "returns the content type without newline" do
@@ -78,7 +78,7 @@ describe Paperclip::FileAdapter do
78
78
  allow(MIME::Types).to receive(:type_for).and_return([])
79
79
  allow(Paperclip).to receive(:run).and_return("application/vnd.ms-office\n")
80
80
  allow_any_instance_of(Paperclip::ContentTypeDetector).
81
- to receive(:type_from_mime_magic).and_return("application/vnd.ms-office")
81
+ to receive(:type_from_marcel).and_return("application/vnd.ms-office")
82
82
 
83
83
  @subject = Paperclip.io_adapters.for(@file)
84
84
  end
@@ -193,9 +193,18 @@ describe Paperclip::UriAdapter do
193
193
 
194
194
  describe "#download_content" do
195
195
  before do
196
- allow_any_instance_of(Paperclip::UriAdapter).to receive(:open).and_return(@open_return)
196
+ allowed_mock =
197
+ if RUBY_VERSION < '2.5'
198
+ allow_any_instance_of(Paperclip::UriAdapter)
199
+ else
200
+ allow(URI)
201
+ end
202
+
203
+ allowed_mock.to receive(:open).and_return(@open_return)
204
+
197
205
  @uri = URI.parse("https://github.com/thoughtbot/paper:clip.jpg")
198
206
  @subject = Paperclip.io_adapters.for(@uri)
207
+ @uri_opener = RUBY_VERSION < '2.5' ? @subject : URI
199
208
  end
200
209
 
201
210
  after do
@@ -204,7 +213,7 @@ describe Paperclip::UriAdapter do
204
213
 
205
214
  context "with default read_timeout" do
206
215
  it "calls open without options" do
207
- expect(@subject).to receive(:open).with(@uri, {}).at_least(1).times
216
+ expect(@uri_opener).to receive(:open).with(@uri, {}).at_least(1).times
208
217
  end
209
218
  end
210
219
 
@@ -214,7 +223,8 @@ describe Paperclip::UriAdapter do
214
223
  end
215
224
 
216
225
  it "calls open with read_timeout option" do
217
- expect(@subject).to receive(:open).with(@uri, read_timeout: 120).at_least(1).times
226
+ expect(@uri_opener)
227
+ .to receive(:open).with(@uri, { read_timeout: 120 }).at_least(1).times
218
228
  end
219
229
  end
220
230
  end
@@ -32,12 +32,18 @@ describe Paperclip::MediaTypeSpoofDetector do
32
32
  end
33
33
 
34
34
  it "does not reject when the extension => content_type is in :content_type_mappings" do
35
+ file = Tempfile.open(["test", ".PEM"])
36
+ file.puts "Certificate!"
37
+ file.close
38
+
39
+ adapter = Paperclip.io_adapters.for(File.new(file.path))
40
+
35
41
  begin
36
42
  Paperclip.options[:content_type_mappings] = { pem: "text/plain" }
37
- file = Tempfile.open(["test", ".PEM"])
38
- file.puts "Certificate!"
39
- file.close
40
- adapter = Paperclip.io_adapters.for(File.new(file.path))
43
+ assert !Paperclip::MediaTypeSpoofDetector.using(adapter, adapter.original_filename, adapter.content_type).spoofed?
44
+
45
+ # As a string.
46
+ Paperclip.options[:content_type_mappings] = { "pem" => "text/plain" }
41
47
  assert !Paperclip::MediaTypeSpoofDetector.using(adapter, adapter.original_filename, adapter.content_type).spoofed?
42
48
  ensure
43
49
  Paperclip.options[:content_type_mappings] = {}
@@ -63,7 +63,7 @@ describe Paperclip do
63
63
  context "Calling Paperclip.run with a logger" do
64
64
  it "passes the defined logger if :log_command is set" do
65
65
  Paperclip.options[:log_command] = true
66
- expect(Terrapin::CommandLine).to receive(:new).with("convert", "stuff", logger: Paperclip.logger).and_return(double(run: nil))
66
+ expect(Terrapin::CommandLine).to receive(:new).with("convert", "stuff", { logger: Paperclip.logger }).and_return(double(run: nil))
67
67
  Paperclip.run("convert", "stuff")
68
68
  end
69
69
  end
@@ -49,6 +49,29 @@ describe Paperclip::Storage::Filesystem do
49
49
  assert_equal @file.read, tempfile.read
50
50
  tempfile.close
51
51
  end
52
+
53
+ it "only issues a delete call once for each unique attachment style when nullifying attachment" do
54
+ @dummy.save
55
+ @dummy.avatar.clear(:thumbnail)
56
+ @dummy.avatar = nil
57
+ assert_equal 3, @dummy.avatar.queued_for_delete.size
58
+
59
+ expect(FileUtils).to receive(:rm).twice
60
+ @dummy.save
61
+
62
+ FileUtils.rm_rf("tmp")
63
+ end
64
+
65
+ it "only issues a delete call once for each unique attachment style when destroying model" do
66
+ @dummy.save
67
+ @dummy.avatar.clear(:thumbnail)
68
+ assert_equal 1, @dummy.avatar.queued_for_delete.size
69
+
70
+ expect(FileUtils).to receive(:rm).twice
71
+ @dummy.destroy
72
+
73
+ FileUtils.rm_rf("tmp")
74
+ end
52
75
  end
53
76
 
54
77
  context "with file that has space in file name" do
@@ -7,6 +7,52 @@ describe Paperclip::Storage::Fog do
7
7
  context "" do
8
8
  before { Fog.mock! }
9
9
 
10
+ context "deleting attachment styles" do
11
+ before do
12
+ rebuild_model styles: { medium: "300x300>", thumb: "100x100>" },
13
+ storage: :fog,
14
+ url: "/:attachment/:style/:filename",
15
+ fog_directory: "paperclip",
16
+ fog_credentials: fixture_file("fog.yml")
17
+ @file = File.open(fixture_file("5k.png"))
18
+ @dummy = Dummy.new
19
+ @dummy.avatar = @file
20
+ @dummy.save
21
+ end
22
+
23
+ after do
24
+ @file.close
25
+ FileUtils.rm_rf("tmp")
26
+ end
27
+
28
+ it "only issues a delete call once for each unique attachment style when nullifying attachment" do
29
+ @dummy.avatar.clear(:thumb)
30
+ @dummy.avatar = nil
31
+ assert_equal 4, @dummy.avatar.queued_for_delete.size
32
+
33
+ original = double("original")
34
+ medium = double("medium")
35
+ thumb = double("thumb")
36
+
37
+ allow(Fog::AWS::Storage::File).to receive(:new).and_return(original, medium, thumb)
38
+
39
+ expect(original).to receive(:destroy).once
40
+ expect(medium).to receive(:destroy).once
41
+ expect(thumb).to receive(:destroy).once
42
+ @dummy.save
43
+ end
44
+
45
+ it "only issues a delete call once for each unique attachment style when destroying model" do
46
+ @dummy.avatar.clear(:thumb)
47
+ assert_equal 1, @dummy.avatar.queued_for_delete.size
48
+
49
+ file = double("file")
50
+ allow(Fog::AWS::Storage::File).to receive(:new).and_return(file)
51
+ expect(file).to receive(:destroy).exactly(3).times
52
+ @dummy.destroy
53
+ end
54
+ end
55
+
10
56
  context "with credentials provided in a path string" do
11
57
  before do
12
58
  rebuild_model styles: { medium: "300x300>", thumb: "100x100>" },
@@ -395,12 +395,22 @@ describe Paperclip::Storage::S3 do
395
395
  allow(@dummy.avatar).to receive(:s3_object).with(:thumbnail).and_return(object)
396
396
 
397
397
  expect(object).to receive(:upload_file).
398
- with(anything, content_type: "image/png",
399
- acl: :"public-read")
398
+ with(
399
+ anything,
400
+ {
401
+ content_type: "image/png",
402
+ acl: :"public-read",
403
+ },
404
+ )
400
405
  expect(object).to receive(:upload_file).
401
- with(anything, content_type: "image/png",
402
- acl: :"public-read",
403
- cache_control: "max-age=31557600")
406
+ with(
407
+ anything,
408
+ {
409
+ content_type: "image/png",
410
+ acl: :"public-read",
411
+ cache_control: "max-age=31557600",
412
+ },
413
+ )
404
414
  @dummy.save
405
415
  end
406
416
 
@@ -411,6 +421,62 @@ describe Paperclip::Storage::S3 do
411
421
  end
412
422
  end
413
423
 
424
+ context "An attachment that uses S3 for storage with acl disabled" do
425
+ before do
426
+ rebuild_model(
427
+ aws2_add_region.merge(
428
+ storage: :s3,
429
+ styles: { thumb: ["90x90#", :jpg] },
430
+ bucket: "bucket",
431
+ s3_acl_enabled: false,
432
+ s3_credentials: {
433
+ "access_key_id" => "12345",
434
+ "secret_access_key" => "54321"
435
+ }
436
+ )
437
+ )
438
+
439
+ @file = File.new(fixture_file("5k.png"), "rb")
440
+ @dummy = Dummy.new
441
+ @dummy.avatar = @file
442
+ @dummy.save
443
+ end
444
+
445
+ context "reprocess" do
446
+ before do
447
+ @object = double
448
+ allow(@dummy.avatar).to receive(:s3_object).with(:original).and_return(@object)
449
+ allow(@dummy.avatar).to receive(:s3_object).with(:thumb).and_return(@object)
450
+ allow(@object).to receive(:get).and_yield(@file.read)
451
+ allow(@object).to receive(:exists?).and_return(true)
452
+ allow(@object).to receive(:download_file).with(anything)
453
+ end
454
+
455
+ it "uploads original" do
456
+ expect(@object).to receive(:upload_file).with(
457
+ anything,
458
+ { content_type: "image/png" },
459
+ ).and_return(true)
460
+ @dummy.avatar.reprocess!
461
+ expect(@object).to receive(:upload_file).with(
462
+ anything,
463
+ { content_type: "image/png" },
464
+ ).and_return(true)
465
+ @dummy.avatar.reprocess!
466
+ end
467
+
468
+ it "doesn't upload original" do
469
+ expect(@object).to receive(:upload_file).with(
470
+ anything,
471
+ { content_type: "image/png" },
472
+ ).and_return(true)
473
+ @dummy.avatar.reprocess!
474
+ end
475
+ end
476
+
477
+ after { @file.close }
478
+ end
479
+
414
480
  context "An attachment that uses S3 for storage and has styles" do
415
481
  before do
416
482
  rebuild_model(
@@ -444,14 +510,18 @@ describe Paperclip::Storage::S3 do
444
510
  it "uploads original" do
445
511
  expect(@object).to receive(:upload_file).with(
446
512
  anything,
447
- content_type: "image/png",
448
- acl: :"public-read"
513
+ {
514
+ content_type: "image/png",
515
+ acl: :"public-read",
516
+ },
449
517
  ).and_return(true)
450
518
  @dummy.avatar.reprocess!
451
519
  expect(@object).to receive(:upload_file).with(
452
520
  anything,
453
- content_type: "image/png",
454
- acl: :"public-read"
521
+ {
522
+ content_type: "image/png",
523
+ acl: :"public-read",
524
+ },
455
525
  ).and_return(true)
456
526
  @dummy.avatar.reprocess!
457
527
  end
@@ -459,8 +529,10 @@ describe Paperclip::Storage::S3 do
459
529
  it "doesn't upload original" do
460
530
  expect(@object).to receive(:upload_file).with(
461
531
  anything,
462
- content_type: "image/png",
463
- acl: :"public-read"
532
+ {
533
+ content_type: "image/png",
534
+ acl: :"public-read",
535
+ },
464
536
  ).and_return(true)
465
537
  @dummy.avatar.reprocess!
466
538
  end
@@ -669,7 +741,7 @@ describe Paperclip::Storage::S3 do
669
741
  object = double
670
742
  allow(@dummy.avatar).to receive(:s3_object).and_return(object)
671
743
 
672
- expect(object).to receive(:presigned_url).with(:get, expires_in: 3600)
744
+ expect(object).to receive(:presigned_url).with(:get, { expires_in: 3600 })
673
745
  @dummy.avatar.expiring_url
674
746
  end
675
747
  end
@@ -684,8 +756,13 @@ describe Paperclip::Storage::S3 do
684
756
  object = double
685
757
  allow(@dummy.avatar).to receive(:s3_object).and_return(object)
686
758
  expect(object).to receive(:presigned_url).
687
- with(:get, expires_in: 3600,
688
- response_content_disposition: "inline")
759
+ with(
760
+ :get,
761
+ {
762
+ expires_in: 3600,
763
+ response_content_disposition: "inline",
764
+ },
765
+ )
689
766
  @dummy.avatar.expiring_url
690
767
  end
691
768
  end
@@ -707,7 +784,13 @@ describe Paperclip::Storage::S3 do
707
784
  object = double
708
785
  allow(@dummy.avatar).to receive(:s3_object).and_return(object)
709
786
  expect(object).to receive(:presigned_url).
710
- with(:get, expires_in: 3600, response_content_type: "image/png")
787
+ with(
788
+ :get,
789
+ {
790
+ expires_in: 3600,
791
+ response_content_type: "image/png",
792
+ },
793
+ )
711
794
  @dummy.avatar.expiring_url
712
795
  end
713
796
  end
@@ -754,14 +837,14 @@ describe Paperclip::Storage::S3 do
754
837
  it "generates a url for the thumb" do
755
838
  object = double
756
839
  allow(@dummy.avatar).to receive(:s3_object).with(:thumb).and_return(object)
757
- expect(object).to receive(:presigned_url).with(:get, expires_in: 1800)
840
+ expect(object).to receive(:presigned_url).with(:get, { expires_in: 1800 })
758
841
  @dummy.avatar.expiring_url(1800, :thumb)
759
842
  end
760
843
 
761
844
  it "generates a url for the default style" do
762
845
  object = double
763
846
  allow(@dummy.avatar).to receive(:s3_object).with(:original).and_return(object)
764
- expect(object).to receive(:presigned_url).with(:get, expires_in: 1800)
847
+ expect(object).to receive(:presigned_url).with(:get, { expires_in: 1800 })
765
848
  @dummy.avatar.expiring_url(1800)
766
849
  end
767
850
  end
@@ -906,7 +989,7 @@ describe Paperclip::Storage::S3 do
906
989
  object = double
907
990
  allow(@dummy.avatar).to receive(:s3_object).and_return(object)
908
991
  expect(object).to receive(:upload_file).
909
- with(anything, content_type: "image/png", acl: :"public-read")
992
+ with(anything, { content_type: "image/png", acl: :"public-read" })
910
993
  @dummy.save
911
994
  end
912
995
 
@@ -940,6 +1023,19 @@ describe Paperclip::Storage::S3 do
940
1023
  end
941
1024
  end
942
1025
 
1026
+ context "and remove, calling S3 Object destroy once per unique style" do
1027
+ before do
1028
+ allow_any_instance_of(Aws::S3::Object).to receive(:exists?).and_return(true)
1029
+ expect_any_instance_of(Aws::S3::Object).to receive(:delete).once
1030
+ @dummy.avatar.clear(:original)
1031
+ @dummy.destroy
1032
+ end
1033
+
1034
+ it "succeeds" do
1035
+ assert true
1036
+ end
1037
+ end
1038
+
943
1039
  context "that the file were missing" do
944
1040
  before do
945
1041
  allow_any_instance_of(Aws::S3::Object).to receive(:exists?).
@@ -1053,10 +1149,14 @@ describe Paperclip::Storage::S3 do
1053
1149
  allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1054
1150
 
1055
1151
  expect(object).to receive(:upload_file).
1056
- with(anything,
1057
- content_type: "image/png",
1058
- acl: :"public-read",
1059
- cache_control: "max-age=31557600")
1152
+ with(
1153
+ anything,
1154
+ {
1155
+ content_type: "image/png",
1156
+ acl: :"public-read",
1157
+ cache_control: "max-age=31557600",
1158
+ },
1159
+ )
1060
1160
  @dummy.save
1061
1161
  end
1062
1162
 
@@ -1094,10 +1194,14 @@ describe Paperclip::Storage::S3 do
1094
1194
  allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1095
1195
 
1096
1196
  expect(object).to receive(:upload_file).
1097
- with(anything,
1197
+ with(
1198
+ anything,
1199
+ {
1098
1200
  content_type: "image/png",
1099
1201
  acl: :"public-read",
1100
- metadata: { "color" => "red" })
1202
+ metadata: { "color" => "red" },
1203
+ },
1204
+ )
1101
1205
  @dummy.save
1102
1206
  end
1103
1207
 
@@ -1135,10 +1239,14 @@ describe Paperclip::Storage::S3 do
1135
1239
  allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1136
1240
 
1137
1241
  expect(object).to receive(:upload_file).
1138
- with(anything,
1242
+ with(
1243
+ anything,
1244
+ {
1139
1245
  content_type: "image/png",
1140
1246
  acl: :"public-read",
1141
- metadata: { "color" => "red" })
1247
+ metadata: { "color" => "red" },
1248
+ },
1249
+ )
1142
1250
  @dummy.save
1143
1251
  end
1144
1252
 
@@ -1177,10 +1285,14 @@ describe Paperclip::Storage::S3 do
1177
1285
  allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1178
1286
 
1179
1287
  expect(object).to receive(:upload_file).
1180
- with(anything,
1288
+ with(
1289
+ anything,
1290
+ {
1181
1291
  content_type: "image/png",
1182
1292
  acl: :"public-read",
1183
- storage_class: "reduced_redundancy")
1293
+ storage_class: "reduced_redundancy",
1294
+ },
1295
+ )
1184
1296
  @dummy.save
1185
1297
  end
1186
1298
 
@@ -1273,9 +1385,14 @@ describe Paperclip::Storage::S3 do
1273
1385
  allow(@dummy.avatar).to receive(:s3_object).with(style).and_return(object)
1274
1386
 
1275
1387
  expect(object).to receive(:upload_file).
1276
- with(anything, content_type: "image/png",
1277
- acl: :"public-read",
1278
- storage_class: :reduced_redundancy)
1388
+ with(
1389
+ anything,
1390
+ {
1391
+ content_type: "image/png",
1392
+ acl: :"public-read",
1393
+ storage_class: :reduced_redundancy,
1394
+ },
1395
+ )
1279
1396
  end
1280
1397
  @dummy.save
1281
1398
  end
@@ -1318,7 +1435,7 @@ describe Paperclip::Storage::S3 do
1318
1435
  allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1319
1436
 
1320
1437
  expect(object).to receive(:upload_file).
1321
- with(anything, content_type: "image/png", acl: :"public-read")
1438
+ with(anything, { content_type: "image/png", acl: :"public-read" })
1322
1439
  @dummy.save
1323
1440
  end
1324
1441
 
@@ -1357,9 +1474,14 @@ describe Paperclip::Storage::S3 do
1357
1474
  allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1358
1475
 
1359
1476
  expect(object).to receive(:upload_file).
1360
- with(anything, content_type: "image/png",
1361
- acl: :"public-read",
1362
- server_side_encryption: "AES256")
1477
+ with(
1478
+ anything,
1479
+ {
1480
+ content_type: "image/png",
1481
+ acl: :"public-read",
1482
+ server_side_encryption: "AES256",
1483
+ },
1484
+ )
1363
1485
  @dummy.save
1364
1486
  end
1365
1487
 
@@ -1397,10 +1519,14 @@ describe Paperclip::Storage::S3 do
1397
1519
  allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1398
1520
 
1399
1521
  expect(object).to receive(:upload_file).
1400
- with(anything,
1401
- content_type: "image/png",
1402
- acl: :"public-read",
1403
- storage_class: :reduced_redundancy)
1522
+ with(
1523
+ anything,
1524
+ {
1525
+ content_type: "image/png",
1526
+ acl: :"public-read",
1527
+ storage_class: :reduced_redundancy,
1528
+ },
1529
+ )
1404
1530
  @dummy.save
1405
1531
  end
1406
1532
 
@@ -1544,7 +1670,7 @@ describe Paperclip::Storage::S3 do
1544
1670
  allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1545
1671
 
1546
1672
  expect(object).to receive(:upload_file).
1547
- with(anything, content_type: "image/png", acl: :"public-read")
1673
+ with(anything, { content_type: "image/png", acl: :"public-read" })
1548
1674
  @dummy.save
1549
1675
  end
1550
1676
 
@@ -1582,7 +1708,7 @@ describe Paperclip::Storage::S3 do
1582
1708
  allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1583
1709
 
1584
1710
  expect(object).to receive(:upload_file).
1585
- with(anything, content_type: "image/png", acl: :private)
1711
+ with(anything, { content_type: "image/png", acl: :private })
1586
1712
  @dummy.save
1587
1713
  end
1588
1714
 
@@ -1628,8 +1754,10 @@ describe Paperclip::Storage::S3 do
1628
1754
 
1629
1755
  expect(object).to receive(:upload_file).
1630
1756
  with(anything,
1631
- content_type: "image/png",
1632
- acl: style == :thumb ? :public_read : :private)
1757
+ {
1758
+ content_type: "image/png",
1759
+ acl: style == :thumb ? :public_read : :private
1760
+ })
1633
1761
  end
1634
1762
  @dummy.save
1635
1763
  end
@@ -1698,10 +1826,14 @@ describe Paperclip::Storage::S3 do
1698
1826
  allow(@dummy.avatar).to receive(:s3_object).with(style).and_return(object)
1699
1827
 
1700
1828
  expect(object).to receive(:upload_file).
1701
- with(anything,
1702
- content_type: "image/png",
1703
- acl: :"public-read",
1704
- content_disposition: 'attachment; filename="Custom Avatar Name.png"')
1829
+ with(
1830
+ anything,
1831
+ {
1832
+ content_type: "image/png",
1833
+ acl: :"public-read",
1834
+ content_disposition: 'attachment; filename="Custom Avatar Name.png"',
1835
+ },
1836
+ )
1705
1837
  end
1706
1838
  @dummy.save
1707
1839
  end