kt-paperclip 7.2.1 → 7.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 206e4e7dd6b6f2ad56c7a0395e9b845a8033c7efa20f19f4ef5c33d09edcbf39
4
- data.tar.gz: 492bfb36e312bd31c4511a91f6b0b4d779d31b5d098f616cb75871c2a6a4e527
3
+ metadata.gz: 213cd04cf7f631853227e9c3fc6d6a38733f3c278907497e1f8e3c2e7a98bac8
4
+ data.tar.gz: 01aec044e7eff086cef50fab323730f617fd455e4ba70ffb99a58d099a4ffde5
5
5
  SHA512:
6
- metadata.gz: 86a39461732fd83389253cc444168d30a9af957362d90694e04852d86619e3d4ac4a84ea71db0d904784de74d5c5e019bdcec86fc18484fce2e26568cf390d55
7
- data.tar.gz: 9506c9fc401cb9ccee3dcfe9186ec8787df2abdc3472f947592d7a79a2e6c32e917cc3eae2de1bfc49f366129a67f793c436b69ecafe501aee0fb7c265662bdc
6
+ metadata.gz: a7e922d52efbde590030651a7cbdca2087aa3c163d6cc498273e9ca57ce5c2b371b44601ccb9e825ee196f1197689438cb91cfca240b6361f259650ea63e5d03
7
+ data.tar.gz: 412ef55d0817f23247e52859d1b39cb1358f55bfd8c8d67cb16df376b42cc2926611b938004d6cec95d7a211895702cb279721322c1ac16e235af954a6f1f40e
data/LICENSE CHANGED
@@ -1,9 +1,9 @@
1
-
2
1
  LICENSE
3
2
 
4
3
  The MIT License
5
4
 
6
5
  Copyright (c) 2008-2016 Jon Yurek and thoughtbot, inc.
6
+ Copyright (c) 2019-2025 Kreeti Technologies Pvt Ltd.
7
7
 
8
8
  Permission is hereby granted, free of charge, to any person obtaining a copy
9
9
  of this software and associated documentation files (the "Software"), to deal
data/{NEWS → OLD_NEWS} RENAMED
@@ -1,5 +1,14 @@
1
1
  [UNRELEASED]
2
+
3
+ * Improvement: Support aws-sdk-s3 >= 1.196.1 and multipart file downloads
4
+
5
+ 7.2.1 (2023-09-09)
2
6
  * Improvement: Support file extension names both as symbols and strings for :content_type_mappings
7
+
8
+ 7.2.0 (2023-05-30)
9
+ * Paperclip schema statements are consistent with ActiveRecord::Migration::Compatibility versioning. Old migrations containing Paperclip schema statements perform the same schema changes both before and after an ActiveRecord version upgrade.
10
+
11
+ 7.0.1 (2021-10-06)
3
12
  * Issue file delete only once per unique style when nullifying attachment or destroying an object. Avoids triggering a rate limit error on Google Cloud Storage.
4
13
 
5
14
  7.0.0 (2021-05-28)
@@ -10,30 +10,31 @@ module Paperclip
10
10
  class Attachment
11
11
  def self.default_options
12
12
  @default_options ||= {
13
- convert_options: {},
14
- default_style: :original,
15
- default_url: "/:attachment/:style/missing.png",
16
- escape_url: true,
17
- restricted_characters: /[&$+,\/:;=?@<>\[\]\{\}\|\\\^~%# ]/,
18
- filename_cleaner: nil,
19
- hash_data: ":class/:attachment/:id/:style/:updated_at",
20
- hash_digest: "SHA1",
21
- interpolator: Paperclip::Interpolations,
22
- only_process: [],
23
- path: ":rails_root/public:url",
24
- preserve_files: false,
25
- processors: [:thumbnail],
26
- source_file_options: {},
27
- storage: :filesystem,
28
- styles: {},
29
- url: "/system/:class/:attachment/:id_partition/:style/:filename",
30
- url_generator: Paperclip::UrlGenerator,
31
- use_default_time_zone: true,
32
- use_timestamp: true,
33
- whiny: Paperclip.options[:whiny] || Paperclip.options[:whiny_thumbnails],
34
- validate_media_type: true,
35
- adapter_options: { hash_digest: Digest::MD5 },
36
- check_validity_before_processing: true
13
+ convert_options: {},
14
+ default_style: :original,
15
+ default_url: "/:attachment/:style/missing.png",
16
+ escape_url: true,
17
+ restricted_characters: /[&$+,\/:;=?@<>\[\]\{\}\|\\\^~%# ]/,
18
+ filename_cleaner: nil,
19
+ hash_data: ":class/:attachment/:id/:style/:updated_at",
20
+ hash_digest: "SHA1",
21
+ interpolator: Paperclip::Interpolations,
22
+ only_process: [],
23
+ path: ":rails_root/public:url",
24
+ preserve_files: false,
25
+ processors: [:thumbnail],
26
+ source_file_options: {},
27
+ storage: :filesystem,
28
+ styles: {},
29
+ url: "/system/:class/:attachment/:id_partition/:style/:filename",
30
+ url_generator: Paperclip::UrlGenerator,
31
+ use_default_time_zone: true,
32
+ use_timestamp: true,
33
+ whiny: Paperclip.options[:whiny] || Paperclip.options[:whiny_thumbnails],
34
+ validate_media_type: true,
35
+ adapter_options: { hash_digest: Digest::MD5 },
36
+ check_validity_before_processing: true,
37
+ return_file_attributes_on_destroy: false
37
38
  }
38
39
  end
39
40
 
@@ -69,6 +70,8 @@ module Paperclip
69
70
  # +interpolator+ - the object used to interpolate filenames and URLs. Defaults to Paperclip::Interpolations
70
71
  # +url_generator+ - the object used to generate URLs, using the interpolator. Defaults to Paperclip::UrlGenerator
71
72
  # +escape_url+ - Perform URI escaping to URLs. Defaults to true
73
+ # +return_file_attributes_on_destroy+ - whether attachment-related attributes should be displayed when
74
+ # destroying a record. Defaults to false.
72
75
  def initialize(name, instance, options = {})
73
76
  @name = name.to_sym
74
77
  @name_string = name.to_s
@@ -563,12 +566,10 @@ module Paperclip
563
566
  path(style) if exists?(style)
564
567
  end.compact
565
568
  end
566
- instance_write(:file_name, nil)
567
- instance_write(:content_type, nil)
568
- instance_write(:file_size, nil)
569
- instance_write(:fingerprint, nil)
570
- instance_write(:created_at, nil) if has_enabled_but_unset_created_at?
571
- instance_write(:updated_at, nil)
569
+
570
+ return if show_attrs_and_destroy_callback_triggered?
571
+
572
+ clear_all_attachment_attributes
572
573
  end
573
574
 
574
575
  def flush_errors #:nodoc:
@@ -613,5 +614,21 @@ module Paperclip
613
614
  def has_enabled_but_unset_created_at?
614
615
  able_to_store_created_at? && !instance_read(:created_at)
615
616
  end
617
+
618
+ # Checks whether the option to show attributes to be destroyed is enabled and whether a destroy callback has been
619
+ # invoked when deleting the entire record.
620
+ def show_attrs_and_destroy_callback_triggered?
621
+ @options[:return_file_attributes_on_destroy] && instance.instance_variable_get(:@_destroy_callback_already_called)
622
+ end
623
+
624
+ # Sets attachment-related attributes to `nil`.
625
+ def clear_all_attachment_attributes
626
+ instance_write(:file_name, nil)
627
+ instance_write(:content_type, nil)
628
+ instance_write(:file_size, nil)
629
+ instance_write(:fingerprint, nil)
630
+ instance_write(:created_at, nil) if has_enabled_but_unset_created_at?
631
+ instance_write(:updated_at, nil)
632
+ end
616
633
  end
617
634
  end
@@ -72,7 +72,7 @@ module Paperclip
72
72
 
73
73
  # Returns the width and height in a format suitable to be passed to Geometry.parse
74
74
  def to_s
75
- s = ""
75
+ s = String.new
76
76
  s << width.to_i.to_s if width > 0
77
77
  s << "x#{height.to_i}" if height > 0
78
78
  s << modifier.to_s
@@ -17,7 +17,7 @@ module Paperclip
17
17
  @fingerprint ||= begin
18
18
  digest = @options.fetch(:hash_digest).new
19
19
  File.open(path, "rb") do |f|
20
- buf = ""
20
+ buf = String.new
21
21
  digest.update(buf) while f.read(16384, buf)
22
22
  end
23
23
  digest.hexdigest
@@ -33,6 +33,15 @@ module Paperclip
33
33
  else
34
34
  begin
35
35
  source.copy_to_local_file(@style, destination.path)
36
+
37
+ # Some sources (like S3) writes to a temporary file first for multi-part downloads then moves
38
+ # it to the final destination path. This means our destination Tempfile reference is stale
39
+ # and reads will return an empty string. For compatibility, we need to copy the contents
40
+ # of the destination file to our current Tempfile instance.
41
+ if destination.size.zero?
42
+ IO.copy_stream(destination.path, destination)
43
+ destination.rewind
44
+ end
36
45
  rescue Errno::EACCES
37
46
  # clean up lingering tempfile if we cannot access source file
38
47
  destination.close(true)
@@ -0,0 +1,18 @@
1
+ fr:
2
+ errors:
3
+ messages:
4
+ in_between: "doit être entre %{min} et %{max}"
5
+ spoofed_media_type: "à du contenu qui ne correspond pas au type déclaré"
6
+
7
+ number:
8
+ human:
9
+ storage_units:
10
+ format: "%n %u"
11
+ units:
12
+ byte:
13
+ one: "Octet"
14
+ other: "Octets"
15
+ kb: "ko"
16
+ mb: "Mo"
17
+ gb: "Go"
18
+ tb: "To"
@@ -1,4 +1,4 @@
1
- gd:
1
+ gd:
2
2
  errors:
3
3
  messages:
4
4
  in_between: "– feumaidh seo a bhith eadar %{min} ’s %{max}"
@@ -11,7 +11,7 @@ module Paperclip
11
11
  def self.included(_base)
12
12
  ActiveRecord::ConnectionAdapters::Table.include TableDefinition
13
13
  ActiveRecord::ConnectionAdapters::TableDefinition.include TableDefinition
14
- ActiveRecord::ConnectionAdapters::AbstractAdapter.include Statements
14
+ ActiveRecord::Migration.include Statements
15
15
  ActiveRecord::Migration::CommandRecorder.include CommandRecorder
16
16
  end
17
17
 
@@ -214,9 +214,9 @@ module Paperclip
214
214
  def find_credentials(creds)
215
215
  case creds
216
216
  when File
217
- YAML::safe_load(ERB.new(File.read(creds.path)).result)
217
+ load_credentials_from_file(creds.path)
218
218
  when String, Pathname
219
- YAML::safe_load(ERB.new(File.read(creds)).result)
219
+ load_credentials_from_file(creds.path)
220
220
  when Hash
221
221
  creds
222
222
  else
@@ -228,6 +228,14 @@ module Paperclip
228
228
  end
229
229
  end
230
230
 
231
+ def load_credentials_from_file(path)
232
+ if Gem::Version.new(Psych::VERSION) >= Gem::Version.new("3.1.0")
233
+ YAML::safe_load(ERB.new(File.read(path)).result, aliases: true)
234
+ else
235
+ YAML::safe_load(ERB.new(File.read(path)).result, [], [], true)
236
+ end
237
+ end
238
+
231
239
  def connection
232
240
  @connection ||= ::Fog::Storage.new(fog_credentials)
233
241
  end
@@ -1,3 +1,4 @@
1
+ # coding: utf-8
1
2
  module Paperclip
2
3
  module Storage
3
4
  # Amazon's S3 file hosting service is a scalable, easy place to store files for
@@ -280,6 +281,16 @@ module Paperclip
280
281
  s3_bucket.object style_name_as_path(style_name)
281
282
  end
282
283
 
284
+ def s3_transfer_manager
285
+ @s3_transfer_manager ||= begin
286
+ if ::Aws::S3.const_defined?(:TransferManager, false)
287
+ ::Aws::S3::TransferManager.new(client: s3_interface.client)
288
+ else
289
+ nil
290
+ end
291
+ end
292
+ end
293
+
283
294
  def use_accelerate_endpoint?
284
295
  !!@use_accelerate_endpoint
285
296
  end
@@ -386,7 +397,12 @@ module Paperclip
386
397
  write_options[:metadata] = @s3_metadata unless @s3_metadata.empty?
387
398
  write_options.merge!(@s3_headers)
388
399
 
389
- s3_object(style).upload_file(file.path, write_options)
400
+ if s3_transfer_manager
401
+ destination = style_name_as_path(style)
402
+ s3_transfer_manager.upload_file(file.path, **write_options, bucket: bucket_name, key: destination)
403
+ else
404
+ s3_object(style).upload_file(file.path, write_options)
405
+ end
390
406
  rescue ::Aws::S3::Errors::NoSuchBucket
391
407
  create_bucket
392
408
  retry
@@ -422,7 +438,13 @@ module Paperclip
422
438
 
423
439
  def copy_to_local_file(style, local_dest_path)
424
440
  log("copying #{path(style)} to local file #{local_dest_path}")
425
- s3_object(style).download_file(local_dest_path)
441
+
442
+ if s3_transfer_manager
443
+ source = style_name_as_path(style)
444
+ s3_transfer_manager.download_file(local_dest_path, bucket: bucket_name, key: source)
445
+ else
446
+ s3_object(style).download_file(local_dest_path)
447
+ end
426
448
  rescue Aws::Errors::ServiceError => e
427
449
  warn("#{e} - cannot copy #{path(style)} to local file #{local_dest_path}")
428
450
  false
@@ -433,7 +455,7 @@ module Paperclip
433
455
  def find_credentials(creds)
434
456
  case creds
435
457
  when File
436
- load_credentials_from_file(creds.path)
458
+ load_credentials_from_file(creds.path)
437
459
  when String, Pathname
438
460
  load_credentials_from_file(creds)
439
461
  when Hash
@@ -1,3 +1,3 @@
1
1
  module Paperclip
2
- VERSION = "7.2.1" unless defined?(Paperclip::VERSION)
2
+ VERSION = "7.3.0" unless defined?(Paperclip::VERSION)
3
3
  end
data/paperclip.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  s.add_dependency("activesupport", ">= 4.2.0")
27
27
  s.add_dependency("mime-types")
28
28
  s.add_dependency("marcel", "~> 1.0.1")
29
- s.add_dependency("terrapin", "~> 0.6.0")
29
+ s.add_dependency("terrapin", ">= 0.6.0", "< 2.0")
30
30
 
31
31
  s.add_development_dependency("activerecord", ">= 4.2.0")
32
32
  s.add_development_dependency("appraisal")
@@ -1267,7 +1267,7 @@ describe Paperclip::Attachment do
1267
1267
  @existing_names.each { |f| assert_file_not_exists(f) }
1268
1268
  end
1269
1269
 
1270
- it "deletes the files when you call #delete" do
1270
+ it "deletes the files when you call #destroy" do
1271
1271
  expect(@attachment).to receive(:instance_write).with(:file_name, nil)
1272
1272
  expect(@attachment).to receive(:instance_write).with(:content_type, nil)
1273
1273
  expect(@attachment).to receive(:instance_write).with(:file_size, nil)
@@ -1277,6 +1277,32 @@ describe Paperclip::Attachment do
1277
1277
  @existing_names.each { |f| assert_file_not_exists(f) }
1278
1278
  end
1279
1279
 
1280
+ it "deletes the files when you destroy the model" do
1281
+ expect(@attachment).to receive(:instance_write).with(:file_name, nil)
1282
+ expect(@attachment).to receive(:instance_write).with(:content_type, nil)
1283
+ expect(@attachment).to receive(:instance_write).with(:file_size, nil)
1284
+ expect(@attachment).to receive(:instance_write).with(:fingerprint, nil)
1285
+ expect(@attachment).to receive(:instance_write).with(:updated_at, nil)
1286
+ @attachment.instance.destroy
1287
+ @existing_names.each { |f| assert_file_not_exists(f) }
1288
+ end
1289
+
1290
+ context "when 'return_file_attributes_on_destroy' option is set to true" do
1291
+ before do
1292
+ @attachment.options[:return_file_attributes_on_destroy] = true
1293
+ end
1294
+
1295
+ it "does not override attachment-related attributes and deletes the files" do
1296
+ expect(@attachment).not_to receive(:instance_write)
1297
+ expect(@attachment).not_to receive(:instance_write)
1298
+ expect(@attachment).not_to receive(:instance_write)
1299
+ expect(@attachment).not_to receive(:instance_write)
1300
+ expect(@attachment).not_to receive(:instance_write)
1301
+ @attachment.instance.destroy
1302
+ @existing_names.each { |f| assert_file_not_exists(f) }
1303
+ end
1304
+ end
1305
+
1280
1306
  context "when keeping old files" do
1281
1307
  before do
1282
1308
  @attachment.options[:keep_old_files] = true
@@ -1304,7 +1330,7 @@ describe Paperclip::Attachment do
1304
1330
  @existing_names.each { |f| assert_file_exists(f) }
1305
1331
  end
1306
1332
 
1307
- it "keeps the files when you call #delete" do
1333
+ it "keeps the files when you call #destroy" do
1308
1334
  expect(@attachment).to receive(:instance_write).with(:file_name, nil)
1309
1335
  expect(@attachment).to receive(:instance_write).with(:content_type, nil)
1310
1336
  expect(@attachment).to receive(:instance_write).with(:file_size, nil)
@@ -1333,7 +1359,7 @@ describe Paperclip::Attachment do
1333
1359
 
1334
1360
  context "An attachment with only a avatar_file_name column" do
1335
1361
  before do
1336
- ActiveRecord::Base.connection.create_table :dummies, force: true do |table|
1362
+ ActiveRecord::Migration.create_table :dummies, force: true do |table|
1337
1363
  table.column :avatar_file_name, :string
1338
1364
  end
1339
1365
  rebuild_class
@@ -1359,7 +1385,7 @@ describe Paperclip::Attachment do
1359
1385
 
1360
1386
  context "and avatar_created_at column" do
1361
1387
  before do
1362
- ActiveRecord::Base.connection.add_column :dummies, :avatar_created_at, :timestamp
1388
+ ActiveRecord::Migration.add_column :dummies, :avatar_created_at, :timestamp
1363
1389
  rebuild_class
1364
1390
  @dummy = Dummy.new
1365
1391
  end
@@ -1396,7 +1422,7 @@ describe Paperclip::Attachment do
1396
1422
 
1397
1423
  context "and avatar_updated_at column" do
1398
1424
  before do
1399
- ActiveRecord::Base.connection.add_column :dummies, :avatar_updated_at, :timestamp
1425
+ ActiveRecord::Migration.add_column :dummies, :avatar_updated_at, :timestamp
1400
1426
  rebuild_class
1401
1427
  @dummy = Dummy.new
1402
1428
  end
@@ -1426,7 +1452,7 @@ describe Paperclip::Attachment do
1426
1452
 
1427
1453
  context "and avatar_content_type column" do
1428
1454
  before do
1429
- ActiveRecord::Base.connection.add_column :dummies, :avatar_content_type, :string
1455
+ ActiveRecord::Migration.add_column :dummies, :avatar_content_type, :string
1430
1456
  rebuild_class
1431
1457
  @dummy = Dummy.new
1432
1458
  end
@@ -1443,7 +1469,7 @@ describe Paperclip::Attachment do
1443
1469
 
1444
1470
  context "and avatar_file_size column" do
1445
1471
  before do
1446
- ActiveRecord::Base.connection.add_column :dummies, :avatar_file_size, :bigint
1472
+ ActiveRecord::Migration.add_column :dummies, :avatar_file_size, :bigint
1447
1473
  rebuild_class
1448
1474
  @dummy = Dummy.new
1449
1475
  end
@@ -1467,7 +1493,7 @@ describe Paperclip::Attachment do
1467
1493
 
1468
1494
  context "and avatar_fingerprint column" do
1469
1495
  before do
1470
- ActiveRecord::Base.connection.add_column :dummies, :avatar_fingerprint, :string
1496
+ ActiveRecord::Migration.add_column :dummies, :avatar_fingerprint, :string
1471
1497
  rebuild_class
1472
1498
  @dummy = Dummy.new
1473
1499
  end
@@ -6,6 +6,33 @@ describe Paperclip::AttachmentAdapter do
6
6
  @attachment = Dummy.new.avatar
7
7
  end
8
8
 
9
+ context "for an attachment that renames the source to the destination" do
10
+ before do
11
+ @file = File.new(fixture_file("5k.png"))
12
+ @file.binmode
13
+
14
+ @attachment.assign(@file)
15
+ @attachment.save
16
+
17
+ allow(@attachment).to receive(:copy_to_local_file) do |style, path|
18
+ FileUtils.cp(@file.path, "#{@file.path}.tmp")
19
+ FileUtils.mv("#{@file.path}.tmp", path)
20
+ end
21
+
22
+ @subject = Paperclip.io_adapters.for(@attachment,
23
+ hash_digest: Digest::MD5)
24
+ end
25
+
26
+ after do
27
+ @file.close
28
+ @subject.close
29
+ end
30
+
31
+ it "handles the case where the source is renamed to the destination" do
32
+ assert_equal @file.read, @subject.read
33
+ end
34
+ end
35
+
9
36
  context "for an attachment" do
10
37
  before do
11
38
  @file = File.new(fixture_file("5k.png"))
@@ -49,7 +49,7 @@ describe "Missing Attachment Styles" do
49
49
  expected_hash = { Dummy: { avatar: [:export, :thumb] } }
50
50
  assert_equal expected_hash, Paperclip.missing_attachments_styles
51
51
 
52
- ActiveRecord::Base.connection.create_table :books, force: true
52
+ ActiveRecord::Migration.create_table :books, force: true
53
53
  class ::Book < ActiveRecord::Base
54
54
  has_attached_file :cover, styles: { small: "x100", large: "1000x1000>" }
55
55
  has_attached_file :sample, styles: { thumb: "x100" }
@@ -11,7 +11,7 @@ describe Paperclip::Schema do
11
11
 
12
12
  after do
13
13
  begin
14
- Dummy.connection.drop_table :dummies
14
+ ActiveRecord::Migration.drop_table :dummies
15
15
  rescue StandardError
16
16
  nil
17
17
  end
@@ -23,7 +23,7 @@ describe Paperclip::Schema do
23
23
  ActiveSupport::Deprecation.silenced = false
24
24
  end
25
25
  it "creates attachment columns" do
26
- Dummy.connection.create_table :dummies, force: true do |t|
26
+ ActiveRecord::Migration.create_table :dummies, force: true do |t|
27
27
  ActiveSupport::Deprecation.silence do
28
28
  t.has_attached_file :avatar
29
29
  end
@@ -38,7 +38,7 @@ describe Paperclip::Schema do
38
38
  end
39
39
 
40
40
  it "displays deprecation warning" do
41
- Dummy.connection.create_table :dummies, force: true do |t|
41
+ ActiveRecord::Migration.create_table :dummies, force: true do |t|
42
42
  assert_deprecated do
43
43
  t.has_attached_file :avatar
44
44
  end
@@ -48,7 +48,7 @@ describe Paperclip::Schema do
48
48
 
49
49
  context "using #attachment" do
50
50
  before do
51
- Dummy.connection.create_table :dummies, force: true do |t|
51
+ ActiveRecord::Migration.create_table :dummies, force: true do |t|
52
52
  t.attachment :avatar
53
53
  end
54
54
  end
@@ -65,7 +65,7 @@ describe Paperclip::Schema do
65
65
 
66
66
  context "using #attachment with options" do
67
67
  before do
68
- Dummy.connection.create_table :dummies, force: true do |t|
68
+ ActiveRecord::Migration.create_table :dummies, force: true do |t|
69
69
  t.attachment :avatar, default: 1, file_name: { default: "default" }
70
70
  end
71
71
  end
@@ -83,13 +83,13 @@ describe Paperclip::Schema do
83
83
 
84
84
  context "within schema statement" do
85
85
  before do
86
- Dummy.connection.create_table :dummies, force: true
86
+ ActiveRecord::Migration.create_table :dummies, force: true
87
87
  end
88
88
 
89
89
  context "migrating up" do
90
90
  context "with single attachment" do
91
91
  before do
92
- Dummy.connection.add_attachment :dummies, :avatar
92
+ ActiveRecord::Migration.add_attachment :dummies, :avatar
93
93
  end
94
94
 
95
95
  it "creates attachment columns" do
@@ -104,7 +104,7 @@ describe Paperclip::Schema do
104
104
 
105
105
  context "with single attachment and options" do
106
106
  before do
107
- Dummy.connection.add_attachment :dummies, :avatar, default: "1", file_name: { default: "default" }
107
+ ActiveRecord::Migration.add_attachment :dummies, :avatar, default: "1", file_name: { default: "default" }
108
108
  end
109
109
 
110
110
  it "sets defaults on columns" do
@@ -119,7 +119,7 @@ describe Paperclip::Schema do
119
119
 
120
120
  context "with multiple attachments" do
121
121
  before do
122
- Dummy.connection.add_attachment :dummies, :avatar, :photo
122
+ ActiveRecord::Migration.add_attachment :dummies, :avatar, :photo
123
123
  end
124
124
 
125
125
  it "creates attachment columns" do
@@ -138,7 +138,7 @@ describe Paperclip::Schema do
138
138
 
139
139
  context "with multiple attachments and options" do
140
140
  before do
141
- Dummy.connection.add_attachment :dummies, :avatar, :photo, default: "1", file_name: { default: "default" }
141
+ ActiveRecord::Migration.add_attachment :dummies, :avatar, :photo, default: "1", file_name: { default: "default" }
142
142
  end
143
143
 
144
144
  it "sets defaults on columns" do
@@ -157,7 +157,7 @@ describe Paperclip::Schema do
157
157
  context "with no attachment" do
158
158
  it "raises an error" do
159
159
  assert_raises ArgumentError do
160
- Dummy.connection.add_attachment :dummies
160
+ ActiveRecord::Migration.add_attachment :dummies
161
161
  end
162
162
  end
163
163
  end
@@ -165,7 +165,7 @@ describe Paperclip::Schema do
165
165
 
166
166
  context "migrating down" do
167
167
  before do
168
- Dummy.connection.change_table :dummies do |t|
168
+ ActiveRecord::Migration.change_table :dummies do |t|
169
169
  t.column :avatar_file_name, :string
170
170
  t.column :avatar_content_type, :string
171
171
  t.column :avatar_file_size, :bigint
@@ -179,7 +179,7 @@ describe Paperclip::Schema do
179
179
  end
180
180
  it "removes the attachment columns" do
181
181
  ActiveSupport::Deprecation.silence do
182
- Dummy.connection.drop_attached_file :dummies, :avatar
182
+ ActiveRecord::Migration.drop_attached_file :dummies, :avatar
183
183
  end
184
184
 
185
185
  columns = Dummy.columns.map { |column| [column.name, column.sql_type] }
@@ -192,7 +192,7 @@ describe Paperclip::Schema do
192
192
 
193
193
  it "displays a deprecation warning" do
194
194
  assert_deprecated do
195
- Dummy.connection.drop_attached_file :dummies, :avatar
195
+ ActiveRecord::Migration.drop_attached_file :dummies, :avatar
196
196
  end
197
197
  end
198
198
  end
@@ -200,7 +200,7 @@ describe Paperclip::Schema do
200
200
  context "using #remove_attachment" do
201
201
  context "with single attachment" do
202
202
  before do
203
- Dummy.connection.remove_attachment :dummies, :avatar
203
+ ActiveRecord::Migration.remove_attachment :dummies, :avatar
204
204
  end
205
205
 
206
206
  it "removes the attachment columns" do
@@ -215,14 +215,14 @@ describe Paperclip::Schema do
215
215
 
216
216
  context "with multiple attachments" do
217
217
  before do
218
- Dummy.connection.change_table :dummies do |t|
218
+ ActiveRecord::Migration.change_table :dummies do |t|
219
219
  t.column :photo_file_name, :string
220
220
  t.column :photo_content_type, :string
221
221
  t.column :photo_file_size, :bigint
222
222
  t.column :photo_updated_at, :datetime
223
223
  end
224
224
 
225
- Dummy.connection.remove_attachment :dummies, :avatar, :photo
225
+ ActiveRecord::Migration.remove_attachment :dummies, :avatar, :photo
226
226
  end
227
227
 
228
228
  it "removes the attachment columns" do
@@ -242,7 +242,7 @@ describe Paperclip::Schema do
242
242
  context "with no attachment" do
243
243
  it "raises an error" do
244
244
  assert_raises ArgumentError do
245
- Dummy.connection.remove_attachment :dummies
245
+ ActiveRecord::Migration.remove_attachment :dummies
246
246
  end
247
247
  end
248
248
  end
@@ -6,6 +6,10 @@ describe Paperclip::Storage::S3 do
6
6
  Aws.config[:stub_responses] = true
7
7
  end
8
8
 
9
+ def s3_uses_transfer_manager?
10
+ defined?(Aws::S3::TransferManager)
11
+ end
12
+
9
13
  def aws2_add_region
10
14
  { s3_region: "us-east-1" }
11
15
  end
@@ -389,27 +393,30 @@ describe Paperclip::Storage::S3 do
389
393
 
390
394
  @dummy = Dummy.new
391
395
  @dummy.avatar = @file
392
-
393
396
  object = double
394
- allow(@dummy.avatar).to receive(:s3_object).with(:original).and_return(object)
395
- allow(@dummy.avatar).to receive(:s3_object).with(:thumbnail).and_return(object)
396
397
 
398
+ if s3_uses_transfer_manager?
399
+ allow(@dummy.avatar).to receive(:s3_transfer_manager).and_return(object)
400
+ else
401
+ allow(@dummy.avatar).to receive(:s3_object).with(:original).and_return(object)
402
+ allow(@dummy.avatar).to receive(:s3_object).with(:thumbnail).and_return(object)
403
+ end
397
404
  expect(object).to receive(:upload_file).
398
405
  with(
399
406
  anything,
400
- {
407
+ hash_including(
401
408
  content_type: "image/png",
402
409
  acl: :"public-read",
403
- },
410
+ ),
404
411
  )
405
412
  expect(object).to receive(:upload_file).
406
413
  with(
407
414
  anything,
408
- {
415
+ hash_including(
409
416
  content_type: "image/png",
410
417
  acl: :"public-read",
411
418
  cache_control: "max-age=31557600",
412
- },
419
+ ),
413
420
  )
414
421
  @dummy.save
415
422
  end
@@ -417,7 +424,12 @@ describe Paperclip::Storage::S3 do
417
424
  after { @file.close }
418
425
 
419
426
  it "succeeds" do
420
- assert_equal @dummy.counter, 7
427
+ if s3_uses_transfer_manager?
428
+ count = 9
429
+ else
430
+ count = 7
431
+ end
432
+ assert_equal @dummy.counter, count
421
433
  end
422
434
  end
423
435
 
@@ -445,22 +457,27 @@ describe Paperclip::Storage::S3 do
445
457
  context "reprocess" do
446
458
  before do
447
459
  @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)
460
+ if s3_uses_transfer_manager?
461
+ allow(@dummy.avatar).to receive(:s3_transfer_manager).and_return(@object)
462
+ allow(@object).to receive(:download_file).with(any_args)
463
+ else
464
+ allow(@dummy.avatar).to receive(:s3_object).with(:original).and_return(@object)
465
+ allow(@dummy.avatar).to receive(:s3_object).with(:thumb).and_return(@object)
466
+ allow(@object).to receive(:get).and_yield(@file.read)
467
+ allow(@object).to receive(:exists?).and_return(true)
468
+ allow(@object).to receive(:download_file).with(anything)
469
+ end
453
470
  end
454
471
 
455
472
  it "uploads original" do
456
473
  expect(@object).to receive(:upload_file).with(
457
474
  anything,
458
- { content_type: "image/png" },
475
+ hash_including(content_type: "image/png"),
459
476
  ).and_return(true)
460
477
  @dummy.avatar.reprocess!
461
478
  expect(@object).to receive(:upload_file).with(
462
479
  anything,
463
- { content_type: "image/png" },
480
+ hash_including(content_type: "image/png"),
464
481
  ).and_return(true)
465
482
  @dummy.avatar.reprocess!
466
483
  end
@@ -468,7 +485,7 @@ describe Paperclip::Storage::S3 do
468
485
  it "doesn't upload original" do
469
486
  expect(@object).to receive(:upload_file).with(
470
487
  anything,
471
- { content_type: "image/png" },
488
+ hash_including(content_type: "image/png"),
472
489
  ).and_return(true)
473
490
  @dummy.avatar.reprocess!
474
491
  end
@@ -500,28 +517,33 @@ describe Paperclip::Storage::S3 do
500
517
  context "reprocess" do
501
518
  before do
502
519
  @object = double
503
- allow(@dummy.avatar).to receive(:s3_object).with(:original).and_return(@object)
504
- allow(@dummy.avatar).to receive(:s3_object).with(:thumb).and_return(@object)
505
- allow(@object).to receive(:get).and_yield(@file.read)
506
- allow(@object).to receive(:exists?).and_return(true)
507
- allow(@object).to receive(:download_file).with(anything)
520
+ if s3_uses_transfer_manager?
521
+ allow(@dummy.avatar).to receive(:s3_transfer_manager).and_return(@object)
522
+ allow(@object).to receive(:download_file).with(any_args)
523
+ else
524
+ allow(@dummy.avatar).to receive(:s3_object).with(:original).and_return(@object)
525
+ allow(@dummy.avatar).to receive(:s3_object).with(:thumb).and_return(@object)
526
+ allow(@object).to receive(:get).and_yield(@file.read)
527
+ allow(@object).to receive(:exists?).and_return(true)
528
+ allow(@object).to receive(:download_file).with(anything)
529
+ end
508
530
  end
509
531
 
510
532
  it "uploads original" do
511
533
  expect(@object).to receive(:upload_file).with(
512
534
  anything,
513
- {
535
+ hash_including(
514
536
  content_type: "image/png",
515
537
  acl: :"public-read",
516
- },
538
+ ),
517
539
  ).and_return(true)
518
540
  @dummy.avatar.reprocess!
519
541
  expect(@object).to receive(:upload_file).with(
520
542
  anything,
521
- {
543
+ hash_including(
522
544
  content_type: "image/png",
523
545
  acl: :"public-read",
524
- },
546
+ ),
525
547
  ).and_return(true)
526
548
  @dummy.avatar.reprocess!
527
549
  end
@@ -529,10 +551,10 @@ describe Paperclip::Storage::S3 do
529
551
  it "doesn't upload original" do
530
552
  expect(@object).to receive(:upload_file).with(
531
553
  anything,
532
- {
554
+ hash_including(
533
555
  content_type: "image/png",
534
556
  acl: :"public-read",
535
- },
557
+ ),
536
558
  ).and_return(true)
537
559
  @dummy.avatar.reprocess!
538
560
  end
@@ -973,9 +995,12 @@ describe Paperclip::Storage::S3 do
973
995
 
974
996
  it "will retry to save again but back off on SlowDown" do
975
997
  allow(@dummy.avatar).to receive(:sleep)
976
- allow_any_instance_of(Aws::S3::Object).to receive(:upload_file).
977
- and_raise(Aws::S3::Errors::SlowDown.new(spy,
978
- spy(status: 503, body: "")))
998
+ err = Aws::S3::Errors::SlowDown.new(spy, spy(status: 503, body: ""))
999
+ if s3_uses_transfer_manager?
1000
+ allow_any_instance_of(Aws::S3::TransferManager).to receive(:upload_file).and_raise(err)
1001
+ else
1002
+ allow_any_instance_of(Aws::S3::Object).to receive(:upload_file).and_raise(err)
1003
+ end
979
1004
  expect { @dummy.save }.to raise_error(Aws::S3::Errors::SlowDown)
980
1005
  expect(@dummy.avatar).to have_received(:sleep).with(1)
981
1006
  expect(@dummy.avatar).to have_received(:sleep).with(2)
@@ -987,9 +1012,13 @@ describe Paperclip::Storage::S3 do
987
1012
  context "and saved" do
988
1013
  before do
989
1014
  object = double
990
- allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1015
+ if s3_uses_transfer_manager?
1016
+ allow(@dummy.avatar).to receive(:s3_transfer_manager).and_return(object)
1017
+ else
1018
+ allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1019
+ end
991
1020
  expect(object).to receive(:upload_file).
992
- with(anything, { content_type: "image/png", acl: :"public-read" })
1021
+ with(anything, hash_including(content_type: "image/png", acl: :"public-read"))
993
1022
  @dummy.save
994
1023
  end
995
1024
 
@@ -1146,16 +1175,19 @@ describe Paperclip::Storage::S3 do
1146
1175
  context "and saved" do
1147
1176
  before do
1148
1177
  object = double
1149
- allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1150
-
1178
+ if s3_uses_transfer_manager?
1179
+ allow(@dummy.avatar).to receive(:s3_transfer_manager).and_return(object)
1180
+ else
1181
+ allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1182
+ end
1151
1183
  expect(object).to receive(:upload_file).
1152
1184
  with(
1153
1185
  anything,
1154
- {
1186
+ hash_including(
1155
1187
  content_type: "image/png",
1156
1188
  acl: :"public-read",
1157
1189
  cache_control: "max-age=31557600",
1158
- },
1190
+ ),
1159
1191
  )
1160
1192
  @dummy.save
1161
1193
  end
@@ -1191,16 +1223,20 @@ describe Paperclip::Storage::S3 do
1191
1223
  context "and saved" do
1192
1224
  before do
1193
1225
  object = double
1194
- allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1226
+ if s3_uses_transfer_manager?
1227
+ allow(@dummy.avatar).to receive(:s3_transfer_manager).and_return(object)
1228
+ else
1229
+ allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1230
+ end
1195
1231
 
1196
1232
  expect(object).to receive(:upload_file).
1197
1233
  with(
1198
1234
  anything,
1199
- {
1235
+ hash_including(
1200
1236
  content_type: "image/png",
1201
1237
  acl: :"public-read",
1202
1238
  metadata: { "color" => "red" },
1203
- },
1239
+ ),
1204
1240
  )
1205
1241
  @dummy.save
1206
1242
  end
@@ -1236,16 +1272,20 @@ describe Paperclip::Storage::S3 do
1236
1272
  context "and saved" do
1237
1273
  before do
1238
1274
  object = double
1239
- allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1275
+ if s3_uses_transfer_manager?
1276
+ allow(@dummy.avatar).to receive(:s3_transfer_manager).and_return(object)
1277
+ else
1278
+ allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1279
+ end
1240
1280
 
1241
1281
  expect(object).to receive(:upload_file).
1242
1282
  with(
1243
1283
  anything,
1244
- {
1284
+ hash_including(
1245
1285
  content_type: "image/png",
1246
1286
  acl: :"public-read",
1247
1287
  metadata: { "color" => "red" },
1248
- },
1288
+ ),
1249
1289
  )
1250
1290
  @dummy.save
1251
1291
  end
@@ -1282,16 +1322,20 @@ describe Paperclip::Storage::S3 do
1282
1322
  context "and saved" do
1283
1323
  before do
1284
1324
  object = double
1285
- allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1325
+ if s3_uses_transfer_manager?
1326
+ allow(@dummy.avatar).to receive(:s3_transfer_manager).and_return(object)
1327
+ else
1328
+ allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1329
+ end
1286
1330
 
1287
1331
  expect(object).to receive(:upload_file).
1288
1332
  with(
1289
1333
  anything,
1290
- {
1334
+ hash_including(
1291
1335
  content_type: "image/png",
1292
1336
  acl: :"public-read",
1293
1337
  storage_class: "reduced_redundancy",
1294
- },
1338
+ ),
1295
1339
  )
1296
1340
  @dummy.save
1297
1341
  end
@@ -1333,7 +1377,11 @@ describe Paperclip::Storage::S3 do
1333
1377
  before do
1334
1378
  object = double
1335
1379
  [:thumb, :original].each do |style|
1336
- allow(@dummy.avatar).to receive(:s3_object).with(style).and_return(object)
1380
+ if s3_uses_transfer_manager?
1381
+ allow(@dummy.avatar).to receive(:s3_transfer_manager).and_return(object)
1382
+ else
1383
+ allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1384
+ end
1337
1385
 
1338
1386
  expected_options = {
1339
1387
  content_type: "image/png",
@@ -1342,7 +1390,7 @@ describe Paperclip::Storage::S3 do
1342
1390
  expected_options.merge!(storage_class: :reduced_redundancy) if style == :thumb
1343
1391
 
1344
1392
  expect(object).to receive(:upload_file).
1345
- with(anything, expected_options)
1393
+ with(anything, hash_including(expected_options))
1346
1394
  end
1347
1395
  @dummy.save
1348
1396
  end
@@ -1382,16 +1430,20 @@ describe Paperclip::Storage::S3 do
1382
1430
  before do
1383
1431
  object = double
1384
1432
  [:thumb, :original].each do |style|
1385
- allow(@dummy.avatar).to receive(:s3_object).with(style).and_return(object)
1433
+ if s3_uses_transfer_manager?
1434
+ allow(@dummy.avatar).to receive(:s3_transfer_manager).and_return(object)
1435
+ else
1436
+ allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1437
+ end
1386
1438
 
1387
1439
  expect(object).to receive(:upload_file).
1388
1440
  with(
1389
1441
  anything,
1390
- {
1442
+ hash_including(
1391
1443
  content_type: "image/png",
1392
1444
  acl: :"public-read",
1393
1445
  storage_class: :reduced_redundancy,
1394
- },
1446
+ ),
1395
1447
  )
1396
1448
  end
1397
1449
  @dummy.save
@@ -1432,10 +1484,14 @@ describe Paperclip::Storage::S3 do
1432
1484
  context "and saved" do
1433
1485
  before do
1434
1486
  object = double
1435
- allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1487
+ if s3_uses_transfer_manager?
1488
+ allow(@dummy.avatar).to receive(:s3_transfer_manager).and_return(object)
1489
+ else
1490
+ allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1491
+ end
1436
1492
 
1437
1493
  expect(object).to receive(:upload_file).
1438
- with(anything, { content_type: "image/png", acl: :"public-read" })
1494
+ with(anything, hash_including(content_type: "image/png", acl: :"public-read"))
1439
1495
  @dummy.save
1440
1496
  end
1441
1497
 
@@ -1471,16 +1527,20 @@ describe Paperclip::Storage::S3 do
1471
1527
  context "and saved" do
1472
1528
  before do
1473
1529
  object = double
1474
- allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1530
+ if s3_uses_transfer_manager?
1531
+ allow(@dummy.avatar).to receive(:s3_transfer_manager).and_return(object)
1532
+ else
1533
+ allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1534
+ end
1475
1535
 
1476
1536
  expect(object).to receive(:upload_file).
1477
1537
  with(
1478
1538
  anything,
1479
- {
1539
+ hash_including(
1480
1540
  content_type: "image/png",
1481
1541
  acl: :"public-read",
1482
1542
  server_side_encryption: "AES256",
1483
- },
1543
+ ),
1484
1544
  )
1485
1545
  @dummy.save
1486
1546
  end
@@ -1516,16 +1576,20 @@ describe Paperclip::Storage::S3 do
1516
1576
  context "and saved" do
1517
1577
  before do
1518
1578
  object = double
1519
- allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1579
+ if s3_uses_transfer_manager?
1580
+ allow(@dummy.avatar).to receive(:s3_transfer_manager).and_return(object)
1581
+ else
1582
+ allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1583
+ end
1520
1584
 
1521
1585
  expect(object).to receive(:upload_file).
1522
1586
  with(
1523
1587
  anything,
1524
- {
1588
+ hash_including(
1525
1589
  content_type: "image/png",
1526
1590
  acl: :"public-read",
1527
1591
  storage_class: :reduced_redundancy,
1528
- },
1592
+ ),
1529
1593
  )
1530
1594
  @dummy.save
1531
1595
  end
@@ -1667,10 +1731,14 @@ describe Paperclip::Storage::S3 do
1667
1731
  context "and saved" do
1668
1732
  before do
1669
1733
  object = double
1670
- allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1734
+ if s3_uses_transfer_manager?
1735
+ allow(@dummy.avatar).to receive(:s3_transfer_manager).and_return(object)
1736
+ else
1737
+ allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1738
+ end
1671
1739
 
1672
1740
  expect(object).to receive(:upload_file).
1673
- with(anything, { content_type: "image/png", acl: :"public-read" })
1741
+ with(anything, hash_including(content_type: "image/png", acl: :"public-read"))
1674
1742
  @dummy.save
1675
1743
  end
1676
1744
 
@@ -1705,10 +1773,14 @@ describe Paperclip::Storage::S3 do
1705
1773
  context "and saved" do
1706
1774
  before do
1707
1775
  object = double
1708
- allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1776
+ if s3_uses_transfer_manager?
1777
+ allow(@dummy.avatar).to receive(:s3_transfer_manager).and_return(object)
1778
+ else
1779
+ allow(@dummy.avatar).to receive(:s3_object).and_return(object)
1780
+ end
1709
1781
 
1710
1782
  expect(object).to receive(:upload_file).
1711
- with(anything, { content_type: "image/png", acl: :private })
1783
+ with(anything, hash_including(content_type: "image/png", acl: :private))
1712
1784
  @dummy.save
1713
1785
  end
1714
1786
 
@@ -1748,16 +1820,21 @@ describe Paperclip::Storage::S3 do
1748
1820
 
1749
1821
  context "and saved" do
1750
1822
  before do
1751
- [:thumb, :original].each do |style|
1752
- object = double
1753
- allow(@dummy.avatar).to receive(:s3_object).with(style).and_return(object)
1823
+ object = double
1824
+ allow(@dummy.avatar).to receive(:s3_transfer_manager).and_return(object) if s3_uses_transfer_manager?
1754
1825
 
1826
+ [:thumb, :original].each do |style|
1827
+ expected_args = { content_type: "image/png", acl: style == :thumb ? :public_read : :private }
1828
+ if s3_uses_transfer_manager?
1829
+ expected_args = expected_args.merge({bucket: "testing", key: "avatars/#{style}/5k.png"})
1830
+ else
1831
+ allow(@dummy.avatar).to receive(:s3_object).with(style).and_return(object)
1832
+ end
1755
1833
  expect(object).to receive(:upload_file).
1756
- with(anything,
1757
- {
1758
- content_type: "image/png",
1759
- acl: style == :thumb ? :public_read : :private
1760
- })
1834
+ with(
1835
+ anything,
1836
+ hash_including(expected_args)
1837
+ )
1761
1838
  end
1762
1839
  @dummy.save
1763
1840
  end
@@ -1821,18 +1898,24 @@ describe Paperclip::Storage::S3 do
1821
1898
 
1822
1899
  context "and saved" do
1823
1900
  before do
1824
- [:thumb, :original].each do |style|
1825
- object = double
1826
- allow(@dummy.avatar).to receive(:s3_object).with(style).and_return(object)
1901
+ object = double
1902
+ allow(@dummy.avatar).to receive(:s3_transfer_manager).and_return(object) if s3_uses_transfer_manager?
1827
1903
 
1904
+ [:thumb, :original].each do |style|
1905
+ expected_args = {
1906
+ content_type: "image/png",
1907
+ acl: :"public-read",
1908
+ content_disposition: 'attachment; filename="Custom Avatar Name.png"'
1909
+ }
1910
+ if s3_uses_transfer_manager?
1911
+ expected_args = expected_args.merge({bucket: "testing", key: "avatars/#{style}/5k.png"})
1912
+ else
1913
+ allow(@dummy.avatar).to receive(:s3_object).with(style).and_return(object)
1914
+ end
1828
1915
  expect(object).to receive(:upload_file).
1829
1916
  with(
1830
1917
  anything,
1831
- {
1832
- content_type: "image/png",
1833
- acl: :"public-read",
1834
- content_disposition: 'attachment; filename="Custom Avatar Name.png"',
1835
- },
1918
+ hash_including(expected_args)
1836
1919
  )
1837
1920
  end
1838
1921
  @dummy.save
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
@@ -28,15 +28,15 @@ module ModelReconstruction
28
28
 
29
29
  def reset_table(_table_name, &block)
30
30
  block ||= lambda { |_table| true }
31
- ActiveRecord::Base.connection.create_table :dummies, **{ force: true }, &block
31
+ ActiveRecord::Migration.create_table :dummies, **{ force: true }, &block
32
32
  end
33
33
 
34
34
  def modify_table(&block)
35
- ActiveRecord::Base.connection.change_table :dummies, &block
35
+ ActiveRecord::Migration.change_table :dummies, &block
36
36
  end
37
37
 
38
38
  def rebuild_model(options = {})
39
- ActiveRecord::Base.connection.create_table :dummies, force: true do |table|
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.2.1
4
+ version: 7.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Surendra Singhi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-09 00:00:00.000000000 Z
11
+ date: 2026-01-31 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
@@ -366,7 +372,7 @@ files:
366
372
  - CONTRIBUTING.md
367
373
  - Gemfile
368
374
  - LICENSE
369
- - NEWS
375
+ - OLD_NEWS
370
376
  - README.md
371
377
  - RELEASING.md
372
378
  - Rakefile
@@ -428,6 +434,7 @@ files:
428
434
  - lib/paperclip/io_adapters/uploaded_file_adapter.rb
429
435
  - lib/paperclip/io_adapters/uri_adapter.rb
430
436
  - lib/paperclip/locales/en.yml
437
+ - lib/paperclip/locales/fr.yml
431
438
  - lib/paperclip/locales/gd.yml
432
439
  - lib/paperclip/logger.rb
433
440
  - lib/paperclip/matchers.rb