paperclip-permanent_records 0.8.1 → 0.9.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 +4 -4
- data/.github/workflows/lint_and_test.yml +16 -14
- data/.rubocop.yml +2 -2
- data/.rubocop_todo.yml +2 -11
- data/Appraisals +22 -11
- data/CHANGELOG.md +13 -1
- data/Gemfile +3 -4
- data/README.md +18 -5
- data/gemfiles/rails_7.1.gemfile +6 -7
- data/gemfiles/rails_7.1_kt_paperclip_7.2.gemfile +17 -0
- data/gemfiles/rails_7.2.gemfile +6 -7
- data/gemfiles/rails_8.0.gemfile +16 -0
- data/gemfiles/rails_8.1.gemfile +16 -0
- data/gemfiles/rails_8.1_permanent_records_7.0.gemfile +17 -0
- data/lib/paperclip/permanent_records/paperclip_patch.rb +3 -1
- data/lib/paperclip/permanent_records/version.rb +1 -1
- data/paperclip-permanent_records.gemspec +3 -3
- data/spec/paperclip/paperclip_patch_spec.rb +35 -0
- data/spec/spec_helper.rb +18 -4
- metadata +13 -13
- data/gemfiles/rails_6.1.gemfile +0 -17
- data/gemfiles/rails_7.0.gemfile +0 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1699d50b8e45db210808642b4293a37462bbfa495bb809b4144591ddbda3f270
|
|
4
|
+
data.tar.gz: '08526446559c2f8da12b07e8081321f71504b73b5427bc9b0d59d5c462dc8116'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b7cb012a9acb4580a70dfc7e31e69954331509992ba80bc34bbf5bef6609aeb052da6a62d8414d571b3f22dc3cf97bf648fc53c17ee23bb63d129dfee21e6ff4
|
|
7
|
+
data.tar.gz: c6295dd1b7af66befb0d0113ab30b16cf494f45ef6235401fac1587a5d6006f00b5e84cc8abee3cfac7f1f5a9291d2621067f2c10ac9d600e61eb41446980d58
|
|
@@ -13,10 +13,10 @@ jobs:
|
|
|
13
13
|
- name: Setup ruby
|
|
14
14
|
uses: ruby/setup-ruby@v1
|
|
15
15
|
with:
|
|
16
|
-
ruby-version: 3.
|
|
17
|
-
|
|
16
|
+
ruby-version: 3.2.11
|
|
17
|
+
rubygems: latest
|
|
18
18
|
- name: Install bundle
|
|
19
|
-
run: bundle
|
|
19
|
+
run: bundle install
|
|
20
20
|
- name: Run rubocop
|
|
21
21
|
run: bundle exec rubocop
|
|
22
22
|
test:
|
|
@@ -25,18 +25,20 @@ jobs:
|
|
|
25
25
|
strategy:
|
|
26
26
|
matrix:
|
|
27
27
|
ruby:
|
|
28
|
-
- 3.
|
|
29
|
-
- 3.
|
|
30
|
-
- 3.
|
|
31
|
-
-
|
|
28
|
+
- 3.2.11
|
|
29
|
+
- 3.3.11
|
|
30
|
+
- 3.4.10
|
|
31
|
+
- 4.0.6
|
|
32
32
|
appraisal:
|
|
33
|
-
- rails_6.1
|
|
34
|
-
- rails_7.0
|
|
35
33
|
- rails_7.1
|
|
36
34
|
- rails_7.2
|
|
37
|
-
|
|
38
|
-
-
|
|
39
|
-
|
|
35
|
+
- rails_8.0
|
|
36
|
+
- rails_8.1
|
|
37
|
+
include:
|
|
38
|
+
- ruby: 3.2.11
|
|
39
|
+
appraisal: rails_7.1-kt_paperclip_7.2
|
|
40
|
+
- ruby: 3.2.11
|
|
41
|
+
appraisal: rails_8.1-permanent_records_7.0
|
|
40
42
|
steps:
|
|
41
43
|
- name: Install system dependencies
|
|
42
44
|
run: sudo apt-get install -y libsqlite3-dev
|
|
@@ -45,9 +47,9 @@ jobs:
|
|
|
45
47
|
uses: ruby/setup-ruby@v1
|
|
46
48
|
with:
|
|
47
49
|
ruby-version: ${{ matrix.ruby }}
|
|
48
|
-
|
|
50
|
+
rubygems: latest
|
|
49
51
|
- name: Install bundle
|
|
50
|
-
run: bundle
|
|
52
|
+
run: bundle install
|
|
51
53
|
- name: Install appraisal
|
|
52
54
|
run: bundle exec appraisal ${{ matrix.appraisal }} bundle install
|
|
53
55
|
- name: Run tests
|
data/.rubocop.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
plugins:
|
|
4
4
|
- rubocop-performance
|
|
5
5
|
- rubocop-rake
|
|
6
6
|
- rubocop-rspec
|
|
@@ -23,7 +23,7 @@ AllCops:
|
|
|
23
23
|
Exclude:
|
|
24
24
|
- 'gemfiles/**/*.gemfile'
|
|
25
25
|
NewCops: enable
|
|
26
|
-
TargetRubyVersion: 3.
|
|
26
|
+
TargetRubyVersion: 3.2
|
|
27
27
|
|
|
28
28
|
Layout/ArgumentAlignment:
|
|
29
29
|
EnforcedStyle: 'with_fixed_indentation'
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on
|
|
3
|
+
# on 2026-08-12 14:04:01 UTC using RuboCop version 1.89.0.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
@@ -8,8 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
# Offense count: 1
|
|
10
10
|
# This cop supports safe autocorrection (--autocorrect).
|
|
11
|
-
# Configuration parameters: Severity, Include.
|
|
12
|
-
# Include: **/*.gemspec
|
|
13
11
|
Gemspec/RequireMFA:
|
|
14
12
|
Exclude:
|
|
15
13
|
- 'paperclip-permanent_records.gemspec'
|
|
@@ -43,17 +41,10 @@ RSpec/ReceiveMessages:
|
|
|
43
41
|
|
|
44
42
|
# Offense count: 1
|
|
45
43
|
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
46
|
-
RSpec/
|
|
44
|
+
RSpec/VerifiedDoubleReference:
|
|
47
45
|
Exclude:
|
|
48
46
|
- 'spec/paperclip/permanent_records_spec.rb'
|
|
49
47
|
|
|
50
|
-
# Offense count: 1
|
|
51
|
-
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
52
|
-
# Configuration parameters: .
|
|
53
|
-
# SupportedStyles: constant, string
|
|
54
|
-
RSpec/VerifiedDoubleReference:
|
|
55
|
-
EnforcedStyle: string
|
|
56
|
-
|
|
57
48
|
# Offense count: 3
|
|
58
49
|
# Configuration parameters: AllowedConstants.
|
|
59
50
|
Style/Documentation:
|
data/Appraisals
CHANGED
|
@@ -1,21 +1,32 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
appraise '
|
|
4
|
-
gem 'rails', '~>
|
|
5
|
-
gem 'sqlite3', '~> 1.4'
|
|
3
|
+
appraise 'rails_7.1' do
|
|
4
|
+
gem 'rails', '~> 7.1.0'
|
|
6
5
|
end
|
|
7
6
|
|
|
8
|
-
appraise 'rails_7.
|
|
9
|
-
gem 'rails', '~> 7.
|
|
10
|
-
gem 'sqlite3', '~> 1.4'
|
|
7
|
+
appraise 'rails_7.2' do
|
|
8
|
+
gem 'rails', '~> 7.2.0'
|
|
11
9
|
end
|
|
12
10
|
|
|
13
|
-
appraise '
|
|
11
|
+
appraise 'rails_8.0' do
|
|
12
|
+
gem 'rails', '~> 8.0.0'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
appraise 'rails_8.1' do
|
|
16
|
+
gem 'rails', '~> 8.1.0'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Smoke-tests the gemspec's kt-paperclip '>= 7.2' floor, which the appraisals
|
|
20
|
+
# above never exercise since they all resolve the latest allowed kt-paperclip.
|
|
21
|
+
appraise 'rails_7.1-kt_paperclip_7.2' do
|
|
14
22
|
gem 'rails', '~> 7.1.0'
|
|
15
|
-
gem '
|
|
23
|
+
gem 'kt-paperclip', '~> 7.2.0'
|
|
16
24
|
end
|
|
17
25
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
# Smoke-tests permanent_records 7.0.0, which is tagged upstream but not yet published to
|
|
27
|
+
# rubygems.org (https://github.com/JackDanger/permanent_records/issues/116), so the appraisals
|
|
28
|
+
# above (which resolve via rubygems) never exercise it.
|
|
29
|
+
appraise 'rails_8.1-permanent_records_7.0' do
|
|
30
|
+
gem 'rails', '~> 8.1.0'
|
|
31
|
+
gem 'permanent_records', git: 'https://github.com/JackDanger/permanent_records.git', tag: '7.0.0'
|
|
21
32
|
end
|
data/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
# (unreleased)
|
|
2
2
|
|
|
3
|
+
# 0.9.0 (2026-08-18)
|
|
4
|
+
|
|
5
|
+
* Add support for ruby 3.4/4.0, rails 8.0/8.1, and kt-paperclip 8
|
|
6
|
+
* Drop support for ruby < 3.2 and rails < 7.2
|
|
7
|
+
* Document that kt-paperclip's `return_file_attributes_on_destroy` option (8.0.0) has no effect on attachments managed by this gem (see README)
|
|
8
|
+
* (dev) Switch to maintained `appraisal2` gem; update rubocop, rspec-rails
|
|
9
|
+
* (dev) Add a regression/canary spec guarding the kt-paperclip `HasAttachedFile` patch against silent upstream changes
|
|
10
|
+
* (dev) Fix sporadic test failures caused by running specs in multiple concurrent processes
|
|
11
|
+
* (dev) Add CI smoke test for permanent_records 7.0.0 (which is tagged upstream but not yet published to rubygems.org)
|
|
12
|
+
* (internal) Github actions: Fix build problems by simply using "latest" rubygems version for both linting and tests (don't use the default from the respective rubies)
|
|
13
|
+
* (internal) Remove the Gemfile's bundler version pin, which conflicted with the Bundler version now installed by "latest" rubygems in CI
|
|
14
|
+
|
|
3
15
|
# 0.8.1 (2024-11-11)
|
|
4
16
|
|
|
5
17
|
* (internal) Add some metadata for rubygems.org
|
|
6
18
|
|
|
7
19
|
# 0.8.0 (2024-11-11)
|
|
8
20
|
|
|
9
|
-
* Add support for ruby 3.3 and rails 7.
|
|
21
|
+
* Add support for ruby 3.3 and rails 7.2
|
|
10
22
|
* Drop support for ruby < 3.0 and rails < 6.1
|
|
11
23
|
* (dev) Fix: gem should be pushed to rubygems.org
|
|
12
24
|
* (dev) Fix github test action to only install the gems based on the current appraisal gemfile
|
data/Gemfile
CHANGED
|
@@ -5,11 +5,10 @@ source 'https://rubygems.org'
|
|
|
5
5
|
# Specify your gem's dependencies in paperclip-permanent_records.gemspec
|
|
6
6
|
gemspec
|
|
7
7
|
|
|
8
|
-
gem '
|
|
9
|
-
gem 'bundler', '~> 2.5'
|
|
8
|
+
gem 'appraisal2'
|
|
10
9
|
gem 'rake', '>= 13.0'
|
|
11
|
-
gem 'rspec-rails', '~>
|
|
12
|
-
gem 'rubocop', '>= 1.
|
|
10
|
+
gem 'rspec-rails', '~> 7.0'
|
|
11
|
+
gem 'rubocop', '>= 1.89'
|
|
13
12
|
gem 'rubocop-performance'
|
|
14
13
|
gem 'rubocop-rake'
|
|
15
14
|
gem 'rubocop-rspec'
|
data/README.md
CHANGED
|
@@ -9,10 +9,9 @@ NOTE: Since paperclip is not maintained any more, we have switched the dependenc
|
|
|
9
9
|
|
|
10
10
|
## Compatibility
|
|
11
11
|
|
|
12
|
-
* rails 7.2: works with kt-paperclip
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* previous versions of ruby/rails/paperclip: please check version 0.7.x of this gem
|
|
12
|
+
* rails 7.1/7.2/8.0/8.1: works with kt-paperclip 7.2 or later and ruby 3.2 or later
|
|
13
|
+
* tested with permanent_records 6.0.0; 7.0.0 is also smoke-tested (it's tagged upstream but not yet published to rubygems.org ([JackDanger/permanent_records#116](https://github.com/JackDanger/permanent_records/issues/116); note that we might drop testing / officially supporting 6.x at some point)
|
|
14
|
+
* previous versions of ruby/rails/paperclip: please check version 0.8.x of this gem
|
|
16
15
|
|
|
17
16
|
Please see `.github/workflows/lint_and_test.yml` and `Appraisals` for what combinations have actually been tested. Usage with other versions
|
|
18
17
|
might cause data loss.
|
|
@@ -48,6 +47,20 @@ This gem does basically two things:
|
|
|
48
47
|
* mark attachments to be deleted in the model's `destroy` method
|
|
49
48
|
(depending on whether the model is actually destroyed or only deleted)
|
|
50
49
|
|
|
50
|
+
### Known issues
|
|
51
|
+
|
|
52
|
+
#### kt-paperclip's `return_file_attributes_on_destroy` option
|
|
53
|
+
|
|
54
|
+
Because the paperclip patch above is applied globally (it overrides
|
|
55
|
+
`Paperclip::HasAttachedFile` itself, not just permanent models), kt-paperclip's
|
|
56
|
+
`return_file_attributes_on_destroy` option (added in 8.0.0) has no effect in
|
|
57
|
+
apps using this gem, even on attachments belonging to non-permanent models.
|
|
58
|
+
|
|
59
|
+
Details: The option relies on ActiveRecord's `@_destroy_callback_already_called` flag being set,
|
|
60
|
+
but this gem calls `queue_all_for_delete` directly, before `super`, ahead of
|
|
61
|
+
the point where ActiveRecord would normally set that flag. Attachment
|
|
62
|
+
attributes are therefore always cleared, regardless of the option's value.
|
|
63
|
+
|
|
51
64
|
## Development
|
|
52
65
|
|
|
53
66
|
Code style: Please use rubocop before you commit (`bundle exec rubocop`) and fix any warnings.
|
|
@@ -61,7 +74,7 @@ To setup tests, make sure all the ruby versions defined in `.github/workflows/li
|
|
|
61
74
|
Assuming you are using [rbenv](https://github.com/rbenv/rbenv) or [rvm](https://rvm.io/), run tests with each of the supported ruby versions:
|
|
62
75
|
|
|
63
76
|
```
|
|
64
|
-
RBENV_VERSION=3.
|
|
77
|
+
RBENV_VERSION=3.2.11 bundle exec appraisal rspec
|
|
65
78
|
```
|
|
66
79
|
|
|
67
80
|
## Install and release
|
data/gemfiles/rails_7.1.gemfile
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
# This file was generated by
|
|
1
|
+
# This file was generated by Appraisal2
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
-
gem "
|
|
6
|
-
gem "bundler", "~> 2.5"
|
|
5
|
+
gem "appraisal2"
|
|
7
6
|
gem "rake", ">= 13.0"
|
|
8
|
-
gem "rspec-rails", "~>
|
|
9
|
-
gem "rubocop", ">= 1.
|
|
7
|
+
gem "rspec-rails", "~> 7.0"
|
|
8
|
+
gem "rubocop", ">= 1.89"
|
|
10
9
|
gem "rubocop-performance"
|
|
11
10
|
gem "rubocop-rake"
|
|
12
11
|
gem "rubocop-rspec"
|
|
13
12
|
gem "rubocop-rspec_rails"
|
|
14
|
-
gem "sqlite3"
|
|
13
|
+
gem "sqlite3"
|
|
15
14
|
gem "rails", "~> 7.1.0"
|
|
16
15
|
|
|
17
|
-
gemspec path
|
|
16
|
+
gemspec :path => "../"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# This file was generated by Appraisal2
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "appraisal2"
|
|
6
|
+
gem "rake", ">= 13.0"
|
|
7
|
+
gem "rspec-rails", "~> 7.0"
|
|
8
|
+
gem "rubocop", ">= 1.89"
|
|
9
|
+
gem "rubocop-performance"
|
|
10
|
+
gem "rubocop-rake"
|
|
11
|
+
gem "rubocop-rspec"
|
|
12
|
+
gem "rubocop-rspec_rails"
|
|
13
|
+
gem "sqlite3"
|
|
14
|
+
gem "rails", "~> 7.1.0"
|
|
15
|
+
gem "kt-paperclip", "~> 7.2.0"
|
|
16
|
+
|
|
17
|
+
gemspec :path => "../"
|
data/gemfiles/rails_7.2.gemfile
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
# This file was generated by
|
|
1
|
+
# This file was generated by Appraisal2
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
-
gem "
|
|
6
|
-
gem "bundler", "~> 2.5"
|
|
5
|
+
gem "appraisal2"
|
|
7
6
|
gem "rake", ">= 13.0"
|
|
8
|
-
gem "rspec-rails", "~>
|
|
9
|
-
gem "rubocop", ">= 1.
|
|
7
|
+
gem "rspec-rails", "~> 7.0"
|
|
8
|
+
gem "rubocop", ">= 1.89"
|
|
10
9
|
gem "rubocop-performance"
|
|
11
10
|
gem "rubocop-rake"
|
|
12
11
|
gem "rubocop-rspec"
|
|
13
12
|
gem "rubocop-rspec_rails"
|
|
14
|
-
gem "sqlite3"
|
|
13
|
+
gem "sqlite3"
|
|
15
14
|
gem "rails", "~> 7.2.0"
|
|
16
15
|
|
|
17
|
-
gemspec path
|
|
16
|
+
gemspec :path => "../"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# This file was generated by Appraisal2
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "appraisal2"
|
|
6
|
+
gem "rake", ">= 13.0"
|
|
7
|
+
gem "rspec-rails", "~> 7.0"
|
|
8
|
+
gem "rubocop", ">= 1.89"
|
|
9
|
+
gem "rubocop-performance"
|
|
10
|
+
gem "rubocop-rake"
|
|
11
|
+
gem "rubocop-rspec"
|
|
12
|
+
gem "rubocop-rspec_rails"
|
|
13
|
+
gem "sqlite3"
|
|
14
|
+
gem "rails", "~> 8.0.0"
|
|
15
|
+
|
|
16
|
+
gemspec :path => "../"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# This file was generated by Appraisal2
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "appraisal2"
|
|
6
|
+
gem "rake", ">= 13.0"
|
|
7
|
+
gem "rspec-rails", "~> 7.0"
|
|
8
|
+
gem "rubocop", ">= 1.89"
|
|
9
|
+
gem "rubocop-performance"
|
|
10
|
+
gem "rubocop-rake"
|
|
11
|
+
gem "rubocop-rspec"
|
|
12
|
+
gem "rubocop-rspec_rails"
|
|
13
|
+
gem "sqlite3"
|
|
14
|
+
gem "rails", "~> 8.1.0"
|
|
15
|
+
|
|
16
|
+
gemspec :path => "../"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# This file was generated by Appraisal2
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "appraisal2"
|
|
6
|
+
gem "rake", ">= 13.0"
|
|
7
|
+
gem "rspec-rails", "~> 7.0"
|
|
8
|
+
gem "rubocop", ">= 1.89"
|
|
9
|
+
gem "rubocop-performance"
|
|
10
|
+
gem "rubocop-rake"
|
|
11
|
+
gem "rubocop-rspec"
|
|
12
|
+
gem "rubocop-rspec_rails"
|
|
13
|
+
gem "sqlite3"
|
|
14
|
+
gem "rails", "~> 8.1.0"
|
|
15
|
+
gem "permanent_records", :git => "https://github.com/JackDanger/permanent_records.git", :tag => "7.0.0"
|
|
16
|
+
|
|
17
|
+
gemspec :path => "../"
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Patch for (kt-)paperclip >= 3.5.0 (based on 7.2.2)
|
|
3
|
+
# Patch for (kt-)paperclip >= 3.5.0 (based on 7.2.2, verified unchanged through 8.0.0).
|
|
4
|
+
# spec/paperclip/paperclip_patch_spec.rb guards against silent upstream drift in
|
|
5
|
+
# the method overridden below.
|
|
4
6
|
|
|
5
7
|
module Paperclip
|
|
6
8
|
class HasAttachedFile
|
|
@@ -25,9 +25,9 @@ Gem::Specification.new do |spec|
|
|
|
25
25
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
26
26
|
spec.require_paths = ['lib']
|
|
27
27
|
|
|
28
|
-
spec.required_ruby_version = '>= 3.
|
|
28
|
+
spec.required_ruby_version = '>= 3.2'
|
|
29
29
|
|
|
30
|
-
spec.add_dependency 'activerecord', '>=
|
|
31
|
-
spec.add_dependency 'kt-paperclip', ['>= 7.2', '<
|
|
30
|
+
spec.add_dependency 'activerecord', '>= 7.1'
|
|
31
|
+
spec.add_dependency 'kt-paperclip', ['>= 7.2', '< 9']
|
|
32
32
|
spec.add_dependency 'permanent_records', '>= 6.0'
|
|
33
33
|
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
# rubocop:disable RSpec/DescribeClass -- describing upstream kt-paperclip source, not a class in this gem
|
|
6
|
+
RSpec.describe 'kt-paperclip HasAttachedFile#add_active_record_callbacks (upstream source)' do
|
|
7
|
+
# lib/paperclip/permanent_records/paperclip_patch.rb fully re-implements
|
|
8
|
+
# Paperclip::HasAttachedFile#add_active_record_callbacks instead of calling
|
|
9
|
+
# super, so it silently stops tracking upstream if that method ever changes
|
|
10
|
+
# shape. This spec reads the actually-installed kt-paperclip source directly
|
|
11
|
+
# off disk and fails loudly if it no longer matches what our override
|
|
12
|
+
# assumes, so drift gets caught here instead of via a subtle production bug.
|
|
13
|
+
let(:upstream_source) do
|
|
14
|
+
gem_path = Gem.loaded_specs.fetch('kt-paperclip').full_gem_path
|
|
15
|
+
file = File.join(gem_path, 'lib', 'paperclip', 'has_attached_file.rb')
|
|
16
|
+
method_source = File.read(file)[/def add_active_record_callbacks.*?\n end/m]
|
|
17
|
+
method_source || raise("could not locate add_active_record_callbacks in #{file}")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'still registers an after_save callback that saves the attachment' do
|
|
21
|
+
expect(upstream_source).to match(/after_save\).*\bsave\b/)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'still registers a before_destroy callback that queues the attachment for deletion' do
|
|
25
|
+
expect(upstream_source).to match(/before_destroy\).*queue_all_for_delete/)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'still branches on after_commit support to flush queued deletes' do
|
|
29
|
+
expect(upstream_source).to include('respond_to?(:after_commit)')
|
|
30
|
+
expect(upstream_source).to match(/after_commit,\s*on:\s*:destroy/)
|
|
31
|
+
expect(upstream_source).to match(/after_destroy\).*flush_deletes/)
|
|
32
|
+
expect(upstream_source).to include('flush_deletes')
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
# rubocop:enable RSpec/DescribeClass
|
data/spec/spec_helper.rb
CHANGED
|
@@ -27,8 +27,12 @@ RSpec.configure do |config|
|
|
|
27
27
|
config.order = :random
|
|
28
28
|
Kernel.srand config.seed
|
|
29
29
|
|
|
30
|
+
config.before(:suite) do
|
|
31
|
+
FileUtils.rm_rf PROCESS_ASSETS_PATH
|
|
32
|
+
end
|
|
33
|
+
|
|
30
34
|
config.after(:suite) do
|
|
31
|
-
FileUtils.rm_rf
|
|
35
|
+
FileUtils.rm_rf PROCESS_ASSETS_PATH
|
|
32
36
|
end
|
|
33
37
|
end
|
|
34
38
|
|
|
@@ -38,9 +42,19 @@ require 'paperclip/permanent_records'
|
|
|
38
42
|
|
|
39
43
|
ActiveRecord::Base.include Paperclip::Glue
|
|
40
44
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
# Falls back to the current process's pid (rather than a constant) so that
|
|
46
|
+
# concurrently-running rspec processes never compute identical attachment
|
|
47
|
+
# paths and race each other in kt-paperclip's filesystem storage adapter.
|
|
48
|
+
TEST_ENV_NUMBER = ENV['TEST_ENV_NUMBER'].presence || Process.pid.to_s
|
|
49
|
+
|
|
50
|
+
# TEST_ASSETS_PATH is shared across all rspec processes (it's not scoped by
|
|
51
|
+
# TEST_ENV_NUMBER), so cleaning it up wholesale would race with any other
|
|
52
|
+
# rspec process concurrently writing under it. Only ever clean up this
|
|
53
|
+
# process's own subtree (referenced by the before(:suite)/after(:suite)
|
|
54
|
+
# hooks configured above).
|
|
55
|
+
PROCESS_ASSETS_PATH = TEST_ASSETS_PATH.join('system', TEST_ENV_NUMBER)
|
|
56
|
+
|
|
57
|
+
Paperclip.interpolates(:test_env_number) { |_, _| TEST_ENV_NUMBER }
|
|
44
58
|
|
|
45
59
|
# set up models
|
|
46
60
|
require 'logger'
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: paperclip-permanent_records
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Maximilian Herold
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activerecord
|
|
@@ -16,14 +15,14 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
18
|
+
version: '7.1'
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
25
|
+
version: '7.1'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
27
|
name: kt-paperclip
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -33,7 +32,7 @@ dependencies:
|
|
|
33
32
|
version: '7.2'
|
|
34
33
|
- - "<"
|
|
35
34
|
- !ruby/object:Gem::Version
|
|
36
|
-
version: '
|
|
35
|
+
version: '9'
|
|
37
36
|
type: :runtime
|
|
38
37
|
prerelease: false
|
|
39
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -43,7 +42,7 @@ dependencies:
|
|
|
43
42
|
version: '7.2'
|
|
44
43
|
- - "<"
|
|
45
44
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '
|
|
45
|
+
version: '9'
|
|
47
46
|
- !ruby/object:Gem::Dependency
|
|
48
47
|
name: permanent_records
|
|
49
48
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -78,10 +77,12 @@ files:
|
|
|
78
77
|
- LICENSE.txt
|
|
79
78
|
- README.md
|
|
80
79
|
- Rakefile
|
|
81
|
-
- gemfiles/rails_6.1.gemfile
|
|
82
|
-
- gemfiles/rails_7.0.gemfile
|
|
83
80
|
- gemfiles/rails_7.1.gemfile
|
|
81
|
+
- gemfiles/rails_7.1_kt_paperclip_7.2.gemfile
|
|
84
82
|
- gemfiles/rails_7.2.gemfile
|
|
83
|
+
- gemfiles/rails_8.0.gemfile
|
|
84
|
+
- gemfiles/rails_8.1.gemfile
|
|
85
|
+
- gemfiles/rails_8.1_permanent_records_7.0.gemfile
|
|
85
86
|
- lib/paperclip/permanent_records.rb
|
|
86
87
|
- lib/paperclip/permanent_records/active_record.rb
|
|
87
88
|
- lib/paperclip/permanent_records/gem_helper.rb
|
|
@@ -91,6 +92,7 @@ files:
|
|
|
91
92
|
- spec/data/models.rb
|
|
92
93
|
- spec/data/schema.rb
|
|
93
94
|
- spec/data/test.png
|
|
95
|
+
- spec/paperclip/paperclip_patch_spec.rb
|
|
94
96
|
- spec/paperclip/permanent_records_spec.rb
|
|
95
97
|
- spec/spec_helper.rb
|
|
96
98
|
homepage: https://github.com/emjot/paperclip-permanent_records
|
|
@@ -101,7 +103,6 @@ metadata:
|
|
|
101
103
|
changelog_uri: https://github.com/emjot/paperclip-permanent_records/blob/main/CHANGELOG.md
|
|
102
104
|
homepage_uri: https://github.com/emjot/paperclip-permanent_records
|
|
103
105
|
source_code_uri: https://github.com/emjot/paperclip-permanent_records
|
|
104
|
-
post_install_message:
|
|
105
106
|
rdoc_options: []
|
|
106
107
|
require_paths:
|
|
107
108
|
- lib
|
|
@@ -109,15 +110,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
109
110
|
requirements:
|
|
110
111
|
- - ">="
|
|
111
112
|
- !ruby/object:Gem::Version
|
|
112
|
-
version: '3.
|
|
113
|
+
version: '3.2'
|
|
113
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
115
|
requirements:
|
|
115
116
|
- - ">="
|
|
116
117
|
- !ruby/object:Gem::Version
|
|
117
118
|
version: '0'
|
|
118
119
|
requirements: []
|
|
119
|
-
rubygems_version: 3.2
|
|
120
|
-
signing_key:
|
|
120
|
+
rubygems_version: 3.7.2
|
|
121
121
|
specification_version: 4
|
|
122
122
|
summary: Make paperclip attachments work with permanent_records
|
|
123
123
|
test_files: []
|
data/gemfiles/rails_6.1.gemfile
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# This file was generated by Appraisal
|
|
2
|
-
|
|
3
|
-
source "https://rubygems.org"
|
|
4
|
-
|
|
5
|
-
gem "appraisal", "~> 2.5"
|
|
6
|
-
gem "bundler", "~> 2.5"
|
|
7
|
-
gem "rake", ">= 13.0"
|
|
8
|
-
gem "rspec-rails", "~> 6.0"
|
|
9
|
-
gem "rubocop", ">= 1.68"
|
|
10
|
-
gem "rubocop-performance"
|
|
11
|
-
gem "rubocop-rake"
|
|
12
|
-
gem "rubocop-rspec"
|
|
13
|
-
gem "rubocop-rspec_rails"
|
|
14
|
-
gem "sqlite3", "~> 1.4"
|
|
15
|
-
gem "rails", "~> 6.1.0"
|
|
16
|
-
|
|
17
|
-
gemspec path: "../"
|
data/gemfiles/rails_7.0.gemfile
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# This file was generated by Appraisal
|
|
2
|
-
|
|
3
|
-
source "https://rubygems.org"
|
|
4
|
-
|
|
5
|
-
gem "appraisal", "~> 2.5"
|
|
6
|
-
gem "bundler", "~> 2.5"
|
|
7
|
-
gem "rake", ">= 13.0"
|
|
8
|
-
gem "rspec-rails", "~> 6.0"
|
|
9
|
-
gem "rubocop", ">= 1.68"
|
|
10
|
-
gem "rubocop-performance"
|
|
11
|
-
gem "rubocop-rake"
|
|
12
|
-
gem "rubocop-rspec"
|
|
13
|
-
gem "rubocop-rspec_rails"
|
|
14
|
-
gem "sqlite3", "~> 1.4"
|
|
15
|
-
gem "rails", "~> 7.0.0"
|
|
16
|
-
|
|
17
|
-
gemspec path: "../"
|