paper_trail_scrapbook 0.1.19 → 0.2.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 +5 -5
- data/.github/workflows/ci.yml +62 -0
- data/.gitignore +3 -0
- data/{.circleci/config.yml → .old_circleci/old_config.yml} +0 -0
- data/.rubocop.yml +2 -2
- data/.ruby-version +1 -1
- data/Changelog.md +12 -1
- data/Gemfile.lock +105 -138
- data/README.md +1 -1
- data/lib/paper_trail_scrapbook/changes.rb +16 -12
- data/lib/paper_trail_scrapbook/config.rb +2 -2
- data/lib/paper_trail_scrapbook/user_journal.rb +1 -1
- data/lib/paper_trail_scrapbook/version.rb +1 -1
- data/lib/paper_trail_scrapbook/version_helpers.rb +4 -4
- data/lib/paper_trail_scrapbook/versions.rb +4 -8
- data/lib/paper_trail_scrapbook.rb +1 -0
- data/paper_trail_scrapbook.gemspec +8 -10
- data/spec/dummy_app/app/models/document.rb +1 -1
- data/spec/dummy_app/app/models/fruit.rb +1 -1
- data/spec/dummy_app/app/models/song.rb +1 -0
- data/spec/dummy_app/config/database.yml +3 -1
- data/spec/dummy_app/config.ru +1 -1
- data/spec/paper_trail_scrapbook/changes_spec.rb +30 -30
- data/spec/paper_trail_scrapbook/chapter_spec.rb +9 -9
- data/spec/paper_trail_scrapbook/journal_entry_spec.rb +0 -1
- data/spec/paper_trail_scrapbook/secondary_chapter_spec.rb +9 -9
- data/spec/paper_trail_scrapbook/versions_spec.rb +1 -4
- data/spec/spec_helper.rb +2 -10
- metadata +30 -62
- data/log/mutant/pts.log +0 -5898
- data/pkg/paper_trail_scrapbook-0.0.2.gem +0 -0
- data/pkg/paper_trail_scrapbook-0.1.6.gem +0 -0
- data/pkg/paper_trail_scrapbook-0.1.7.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1ab2da369e6db07c4fdf12e63335ffd33e269beee77b903d6d12db40d8c0755f
|
4
|
+
data.tar.gz: fc86adc663d1695905ef6500554962f2cdf7e5127b644f43e82afd00e529e05a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08828b154f081625bce0fe40bac7dcc6f60df04098671e04798fc271bd68eed7f7f1e613c090ce7589e78089de16c4defa841d5c534e18fced196fe55c720d35'
|
7
|
+
data.tar.gz: fd9d86505bc9375e67576e8bc8aae247d824e8bf1ab3cd029aca34f5d15f92f42435ad20e48be32bed56dbd4df500b3c5758f20cb56082be0b6a222adc662aa9
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub. They are
|
2
|
+
# provided by a third-party and are governed by separate terms of service,
|
3
|
+
# privacy policy, and support documentation.
|
4
|
+
#
|
5
|
+
# This workflow will install a prebuilt Ruby version, install dependencies, and
|
6
|
+
# run tests and linters.
|
7
|
+
name: "CI"
|
8
|
+
on:
|
9
|
+
push:
|
10
|
+
branches: [ "master" ]
|
11
|
+
pull_request:
|
12
|
+
branches: [ "master" ]
|
13
|
+
jobs:
|
14
|
+
test:
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
services:
|
17
|
+
postgres:
|
18
|
+
image: postgres
|
19
|
+
ports:
|
20
|
+
- "5432:5432"
|
21
|
+
env:
|
22
|
+
POSTGRES_DB: pts_db
|
23
|
+
POSTGRES_USER: postgres
|
24
|
+
POSTGRES_PASSWORD: postgres
|
25
|
+
|
26
|
+
# needed because the postgres container does not provide a healthcheck
|
27
|
+
options: >-
|
28
|
+
--health-cmd pg_isready
|
29
|
+
--health-interval 10s
|
30
|
+
--health-timeout 5s
|
31
|
+
--health-retries 5
|
32
|
+
env:
|
33
|
+
RAILS_ENV: test
|
34
|
+
DATABASE_NAME: pts_db
|
35
|
+
DATABASE_USER: postgres
|
36
|
+
DATABASE_PASSWORD: postgres
|
37
|
+
DATABASE_HOST: "127.0.0.1"
|
38
|
+
|
39
|
+
steps:
|
40
|
+
- name: Checkout code
|
41
|
+
uses: actions/checkout@v3
|
42
|
+
- name: Install Ruby and gems
|
43
|
+
uses: ruby/setup-ruby@v1
|
44
|
+
with:
|
45
|
+
bundler-cache: true
|
46
|
+
- name: Set up database
|
47
|
+
run: bundle exec rake prepare
|
48
|
+
# Add or replace test runners here
|
49
|
+
- name: Run tests
|
50
|
+
run: bundle exec rspec
|
51
|
+
|
52
|
+
lint:
|
53
|
+
runs-on: ubuntu-latest
|
54
|
+
steps:
|
55
|
+
- name: Checkout code
|
56
|
+
uses: actions/checkout@v3
|
57
|
+
- name: Install Ruby and gems
|
58
|
+
uses: ruby/setup-ruby@v1
|
59
|
+
with:
|
60
|
+
bundler-cache: true
|
61
|
+
- name: Lint Ruby files
|
62
|
+
run: bundle exec rubocop
|
data/.gitignore
CHANGED
File without changes
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.7
|
data/Changelog.md
CHANGED
@@ -5,6 +5,18 @@ recommendations of [keepachangelog.com](http://keepachangelog.com/).
|
|
5
5
|
|
6
6
|
## Unreleased
|
7
7
|
|
8
|
+
## 0.1.21 (2021-02-16) Rails 6.1 compatibility
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
|
12
|
+
- Updated dependency gem versions
|
13
|
+
|
14
|
+
## 0.1.20 (2020-12-24) Bugfix Release
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
|
18
|
+
- Missing require for new Versions
|
19
|
+
|
8
20
|
## 0.1.11 (2018-08-09) Functional Release
|
9
21
|
|
10
22
|
### Breaking Changes
|
@@ -77,4 +89,3 @@ recommendations of [keepachangelog.com](http://keepachangelog.com/).
|
|
77
89
|
### Fixed
|
78
90
|
|
79
91
|
- None
|
80
|
-
|
data/Gemfile.lock
CHANGED
@@ -1,198 +1,165 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
paper_trail_scrapbook (0.
|
4
|
+
paper_trail_scrapbook (0.2.0)
|
5
5
|
activerecord
|
6
6
|
adamantium
|
7
7
|
concord
|
8
|
-
paper_trail (>=
|
8
|
+
paper_trail (>= 11, < 13)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
rack (~> 2.0)
|
13
|
+
actionpack (6.1.6.1)
|
14
|
+
actionview (= 6.1.6.1)
|
15
|
+
activesupport (= 6.1.6.1)
|
16
|
+
rack (~> 2.0, >= 2.0.9)
|
18
17
|
rack-test (>= 0.6.3)
|
19
18
|
rails-dom-testing (~> 2.0)
|
20
|
-
rails-html-sanitizer (~> 1.0, >= 1.0
|
21
|
-
actionview (
|
22
|
-
activesupport (=
|
19
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
20
|
+
actionview (6.1.6.1)
|
21
|
+
activesupport (= 6.1.6.1)
|
23
22
|
builder (~> 3.1)
|
24
23
|
erubi (~> 1.4)
|
25
24
|
rails-dom-testing (~> 2.0)
|
26
|
-
rails-html-sanitizer (~> 1.
|
27
|
-
activemodel (
|
28
|
-
activesupport (=
|
29
|
-
activerecord (
|
30
|
-
activemodel (=
|
31
|
-
activesupport (=
|
32
|
-
|
33
|
-
activesupport (5.2.3)
|
25
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
26
|
+
activemodel (6.1.6.1)
|
27
|
+
activesupport (= 6.1.6.1)
|
28
|
+
activerecord (6.1.6.1)
|
29
|
+
activemodel (= 6.1.6.1)
|
30
|
+
activesupport (= 6.1.6.1)
|
31
|
+
activesupport (6.1.6.1)
|
34
32
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
35
|
-
i18n (>=
|
36
|
-
minitest (
|
37
|
-
tzinfo (~>
|
33
|
+
i18n (>= 1.6, < 2)
|
34
|
+
minitest (>= 5.1)
|
35
|
+
tzinfo (~> 2.0)
|
36
|
+
zeitwerk (~> 2.3)
|
38
37
|
adamantium (0.2.0)
|
39
38
|
ice_nine (~> 0.11.0)
|
40
39
|
memoizable (~> 0.4.0)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
equalizer (~> 0.0.11)
|
45
|
-
arel (9.0.0)
|
46
|
-
ast (2.3.0)
|
47
|
-
builder (3.2.3)
|
48
|
-
codeclimate-test-reporter (1.0.8)
|
40
|
+
ast (2.4.2)
|
41
|
+
builder (3.2.4)
|
42
|
+
codeclimate-test-reporter (1.0.9)
|
49
43
|
simplecov (<= 0.13)
|
50
|
-
concord (0.1.
|
44
|
+
concord (0.1.6)
|
51
45
|
adamantium (~> 0.2.0)
|
52
46
|
equalizer (~> 0.0.9)
|
53
|
-
concurrent-ruby (1.1.
|
54
|
-
crass (1.0.
|
55
|
-
database_cleaner (
|
56
|
-
|
47
|
+
concurrent-ruby (1.1.10)
|
48
|
+
crass (1.0.6)
|
49
|
+
database_cleaner (2.0.1)
|
50
|
+
database_cleaner-active_record (~> 2.0.0)
|
51
|
+
database_cleaner-active_record (2.0.1)
|
52
|
+
activerecord (>= 5.a)
|
53
|
+
database_cleaner-core (~> 2.0.0)
|
54
|
+
database_cleaner-core (2.0.1)
|
55
|
+
diff-lcs (1.5.0)
|
57
56
|
docile (1.1.5)
|
58
57
|
equalizer (0.0.11)
|
59
|
-
erubi (1.
|
60
|
-
ffaker (2.
|
61
|
-
i18n (1.
|
58
|
+
erubi (1.11.0)
|
59
|
+
ffaker (2.21.0)
|
60
|
+
i18n (1.12.0)
|
62
61
|
concurrent-ruby (~> 1.0)
|
63
62
|
ice_nine (0.11.2)
|
64
|
-
json (2.
|
65
|
-
loofah (2.
|
63
|
+
json (2.6.2)
|
64
|
+
loofah (2.18.0)
|
66
65
|
crass (~> 1.0.2)
|
67
66
|
nokogiri (>= 1.5.9)
|
68
67
|
memoizable (0.4.2)
|
69
68
|
thread_safe (~> 0.3, >= 0.3.1)
|
70
|
-
method_source (0.
|
71
|
-
mini_portile2 (2.
|
72
|
-
minitest (5.
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
concord (~> 0.1.5)
|
79
|
-
equalizer (~> 0.0.9)
|
80
|
-
ice_nine (~> 0.11.0)
|
81
|
-
procto (~> 0.0.2)
|
82
|
-
mutant (0.8.14)
|
83
|
-
abstract_type (~> 0.0.7)
|
84
|
-
adamantium (~> 0.2.0)
|
85
|
-
anima (~> 0.3.0)
|
86
|
-
ast (~> 2.2)
|
87
|
-
concord (~> 0.1.5)
|
88
|
-
diff-lcs (~> 1.3)
|
89
|
-
equalizer (~> 0.0.9)
|
90
|
-
ice_nine (~> 0.11.1)
|
91
|
-
memoizable (~> 0.4.2)
|
92
|
-
morpher (~> 0.2.6)
|
93
|
-
parallel (~> 1.3)
|
94
|
-
parser (>= 2.3.1.4, < 2.5)
|
95
|
-
procto (~> 0.0.2)
|
96
|
-
regexp_parser (~> 0.4.3)
|
97
|
-
unparser (~> 0.2.5)
|
98
|
-
mutant-rspec (0.8.14)
|
99
|
-
mutant (~> 0.8.14)
|
100
|
-
rspec-core (>= 3.4.0, < 3.7.0)
|
101
|
-
nokogiri (1.10.8)
|
102
|
-
mini_portile2 (~> 2.4.0)
|
103
|
-
paper_trail (10.2.1)
|
104
|
-
activerecord (>= 4.2, < 6.1)
|
69
|
+
method_source (1.0.0)
|
70
|
+
mini_portile2 (2.8.0)
|
71
|
+
minitest (5.16.2)
|
72
|
+
nokogiri (1.13.8)
|
73
|
+
mini_portile2 (~> 2.8.0)
|
74
|
+
racc (~> 1.4)
|
75
|
+
paper_trail (12.3.0)
|
76
|
+
activerecord (>= 5.2)
|
105
77
|
request_store (~> 1.1)
|
106
|
-
parallel (1.
|
107
|
-
parser (
|
108
|
-
ast (~> 2.
|
109
|
-
pg (
|
110
|
-
|
111
|
-
|
112
|
-
rack (2.2
|
113
|
-
|
114
|
-
rack (>= 1.0, < 3)
|
78
|
+
parallel (1.22.1)
|
79
|
+
parser (3.1.2.1)
|
80
|
+
ast (~> 2.4.1)
|
81
|
+
pg (1.4.3)
|
82
|
+
racc (1.6.0)
|
83
|
+
rack (2.2.4)
|
84
|
+
rack-test (2.0.2)
|
85
|
+
rack (>= 1.3)
|
115
86
|
rails-dom-testing (2.0.3)
|
116
87
|
activesupport (>= 4.2.0)
|
117
88
|
nokogiri (>= 1.6)
|
118
|
-
rails-html-sanitizer (1.
|
119
|
-
loofah (~> 2.
|
120
|
-
railties (
|
121
|
-
actionpack (=
|
122
|
-
activesupport (=
|
89
|
+
rails-html-sanitizer (1.4.3)
|
90
|
+
loofah (~> 2.3)
|
91
|
+
railties (6.1.6.1)
|
92
|
+
actionpack (= 6.1.6.1)
|
93
|
+
activesupport (= 6.1.6.1)
|
123
94
|
method_source
|
124
|
-
rake (>=
|
125
|
-
thor (
|
126
|
-
rainbow (3.
|
127
|
-
rake (13.0.
|
128
|
-
regexp_parser (
|
129
|
-
request_store (1.5.
|
95
|
+
rake (>= 12.2)
|
96
|
+
thor (~> 1.0)
|
97
|
+
rainbow (3.1.1)
|
98
|
+
rake (13.0.6)
|
99
|
+
regexp_parser (2.5.0)
|
100
|
+
request_store (1.5.1)
|
130
101
|
rack (>= 1.4)
|
131
|
-
|
132
|
-
|
133
|
-
|
102
|
+
rexml (3.2.5)
|
103
|
+
rspec-core (3.11.0)
|
104
|
+
rspec-support (~> 3.11.0)
|
105
|
+
rspec-expectations (3.11.0)
|
134
106
|
diff-lcs (>= 1.2.0, < 2.0)
|
135
|
-
rspec-support (~> 3.
|
136
|
-
rspec-jumpstart (1.1.
|
137
|
-
rspec-mocks (3.
|
107
|
+
rspec-support (~> 3.11.0)
|
108
|
+
rspec-jumpstart (1.1.5)
|
109
|
+
rspec-mocks (3.11.1)
|
138
110
|
diff-lcs (>= 1.2.0, < 2.0)
|
139
|
-
rspec-support (~> 3.
|
140
|
-
rspec-rails (
|
141
|
-
actionpack (>=
|
142
|
-
activesupport (>=
|
143
|
-
railties (>=
|
144
|
-
rspec-core (~> 3.
|
145
|
-
rspec-expectations (~> 3.
|
146
|
-
rspec-mocks (~> 3.
|
147
|
-
rspec-support (~> 3.
|
148
|
-
rspec-support (3.
|
149
|
-
rspec_junit_formatter (0.
|
111
|
+
rspec-support (~> 3.11.0)
|
112
|
+
rspec-rails (5.1.2)
|
113
|
+
actionpack (>= 5.2)
|
114
|
+
activesupport (>= 5.2)
|
115
|
+
railties (>= 5.2)
|
116
|
+
rspec-core (~> 3.10)
|
117
|
+
rspec-expectations (~> 3.10)
|
118
|
+
rspec-mocks (~> 3.10)
|
119
|
+
rspec-support (~> 3.10)
|
120
|
+
rspec-support (3.11.0)
|
121
|
+
rspec_junit_formatter (0.5.1)
|
150
122
|
rspec-core (>= 2, < 4, != 2.12.0)
|
151
|
-
rubocop (
|
123
|
+
rubocop (1.35.0)
|
124
|
+
json (~> 2.3)
|
152
125
|
parallel (~> 1.10)
|
153
|
-
parser (>=
|
154
|
-
powerpack (~> 0.1)
|
126
|
+
parser (>= 3.1.2.1)
|
155
127
|
rainbow (>= 2.2.2, < 4.0)
|
128
|
+
regexp_parser (>= 1.8, < 3.0)
|
129
|
+
rexml (>= 3.2.5, < 4.0)
|
130
|
+
rubocop-ast (>= 1.20.1, < 2.0)
|
156
131
|
ruby-progressbar (~> 1.7)
|
157
|
-
unicode-display_width (
|
158
|
-
rubocop-
|
159
|
-
|
160
|
-
|
132
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
133
|
+
rubocop-ast (1.21.0)
|
134
|
+
parser (>= 3.1.1.0)
|
135
|
+
rubocop-rspec (2.12.1)
|
136
|
+
rubocop (~> 1.31)
|
137
|
+
ruby-progressbar (1.11.0)
|
161
138
|
simplecov (0.13.0)
|
162
139
|
docile (~> 1.1.0)
|
163
140
|
json (>= 1.8, < 3)
|
164
141
|
simplecov-html (~> 0.10.0)
|
165
142
|
simplecov-html (0.10.2)
|
166
|
-
thor (
|
143
|
+
thor (1.2.1)
|
167
144
|
thread_safe (0.3.6)
|
168
145
|
timecop (0.8.1)
|
169
|
-
tzinfo (
|
170
|
-
|
171
|
-
unicode-display_width (
|
172
|
-
|
173
|
-
abstract_type (~> 0.0.7)
|
174
|
-
adamantium (~> 0.2.0)
|
175
|
-
concord (~> 0.1.5)
|
176
|
-
diff-lcs (~> 1.3)
|
177
|
-
equalizer (~> 0.0.9)
|
178
|
-
parser (>= 2.3.1.2, < 2.5)
|
179
|
-
procto (~> 0.0.2)
|
146
|
+
tzinfo (2.0.5)
|
147
|
+
concurrent-ruby (~> 1.0)
|
148
|
+
unicode-display_width (2.2.0)
|
149
|
+
zeitwerk (2.6.0)
|
180
150
|
|
181
151
|
PLATFORMS
|
182
152
|
ruby
|
183
|
-
x86_64-darwin-20
|
184
153
|
|
185
154
|
DEPENDENCIES
|
186
155
|
codeclimate-test-reporter (~> 1.0.7)
|
187
|
-
database_cleaner
|
156
|
+
database_cleaner
|
188
157
|
ffaker (~> 2.5)
|
189
|
-
loofah
|
190
|
-
mutant
|
191
|
-
mutant-rspec
|
158
|
+
loofah
|
192
159
|
paper_trail_scrapbook!
|
193
|
-
pg
|
160
|
+
pg
|
194
161
|
rack (>= 2.0.6)
|
195
|
-
railties (
|
162
|
+
railties (>= 5.2.3)
|
196
163
|
rake (~> 13.0.1)
|
197
164
|
rspec-jumpstart
|
198
165
|
rspec-rails
|
@@ -203,4 +170,4 @@ DEPENDENCIES
|
|
203
170
|
timecop (~> 0.8.0)
|
204
171
|
|
205
172
|
BUNDLED WITH
|
206
|
-
2.2.
|
173
|
+
2.2.26
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Paper Trail Scrapbook
|
2
2
|
|
3
|
-
|
3
|
+
|
4
4
|
[](https://badge.fury.io/rb/paper_trail_scrapbook)
|
5
5
|
|
6
6
|
Human Readable audit reporting for users of [PaperTrail](https://github.com/paper-trail-gem/paper_trail) gem.
|
@@ -30,9 +30,9 @@ module PaperTrailScrapbook
|
|
30
30
|
def change_log
|
31
31
|
text =
|
32
32
|
changes
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
.map { |k, v| digest(k, v) }
|
34
|
+
.compact
|
35
|
+
.join("\n")
|
36
36
|
|
37
37
|
text = text.gsub(' id:', ':') if PaperTrailScrapbook.config.drop_id_suffix
|
38
38
|
text
|
@@ -40,8 +40,8 @@ module PaperTrailScrapbook
|
|
40
40
|
|
41
41
|
private
|
42
42
|
|
43
|
-
def polymorphic?(
|
44
|
-
|
43
|
+
def polymorphic?(key)
|
44
|
+
key.to_s.start_with?(POLYMORPH_BT_INDICATOR)
|
45
45
|
end
|
46
46
|
|
47
47
|
def digest(key, values)
|
@@ -82,7 +82,8 @@ module PaperTrailScrapbook
|
|
82
82
|
def assoc_target(key)
|
83
83
|
x = build_associations[key]
|
84
84
|
return x unless polymorphic?(x)
|
85
|
-
|
85
|
+
|
86
|
+
ref = "#{x[1..]}_type"
|
86
87
|
|
87
88
|
# try object changes to see if the belongs_to class is specified
|
88
89
|
latest_class = changes[ref]&.last
|
@@ -90,16 +91,19 @@ module PaperTrailScrapbook
|
|
90
91
|
if latest_class.nil? && create?
|
91
92
|
# try the db default class
|
92
93
|
# for creates where the object changes do not specify this it
|
93
|
-
# is most likely because the default ==
|
94
|
+
# is most likely because the default == type selected so
|
94
95
|
# the default was not changed and therefore is not in
|
95
96
|
# object changes
|
96
|
-
|
97
|
-
latest_class = orig_instance[ref.to_sym]
|
97
|
+
latest_class = orig_instance[ref.to_sym]
|
98
98
|
end
|
99
99
|
|
100
100
|
Object.const_get(latest_class.classify)
|
101
101
|
end
|
102
102
|
|
103
|
+
def orig_instance
|
104
|
+
Object.const_get(version.item_type.classify).new
|
105
|
+
end
|
106
|
+
|
103
107
|
def assoc_klass(name, options = {})
|
104
108
|
direct_class = options[:class_name]
|
105
109
|
poly = options[:polymorphic]
|
@@ -119,9 +123,9 @@ module PaperTrailScrapbook
|
|
119
123
|
@build_associations ||=
|
120
124
|
Hash[
|
121
125
|
klass
|
122
|
-
|
123
|
-
|
124
|
-
|
126
|
+
.reflect_on_all_associations
|
127
|
+
.select { |a| a.macro.equal?(:belongs_to) }
|
128
|
+
.map { |x| [x.foreign_key.to_s, assoc_klass(x.name, x.options)] }
|
125
129
|
]
|
126
130
|
end
|
127
131
|
|
@@ -8,8 +8,8 @@ module PaperTrailScrapbook
|
|
8
8
|
include Singleton
|
9
9
|
|
10
10
|
DEFAULT_TIME_FORMAT = '%A, %d %b %Y at %l:%M %p'
|
11
|
-
DEFAULT_EVENTS = { 'create'
|
12
|
-
'update'
|
11
|
+
DEFAULT_EVENTS = { 'create' => 'created',
|
12
|
+
'update' => 'updated',
|
13
13
|
'destroy' => 'destroyed' }.freeze
|
14
14
|
|
15
15
|
SCRUB_COLUMNS = %w[updated_at created_at id].freeze
|
@@ -53,10 +53,10 @@ module PaperTrailScrapbook
|
|
53
53
|
|
54
54
|
def whodunnit_instance(author)
|
55
55
|
instance = begin
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
whodunnit_class.find(author)
|
57
|
+
rescue StandardError
|
58
|
+
config.invalid_whodunnit.call(author)
|
59
|
+
end
|
60
60
|
|
61
61
|
return instance.to_whodunnit if instance.respond_to?(:to_whodunnit)
|
62
62
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module PaperTrailScrapbook
|
4
|
+
# Fetches available versions and related version info
|
5
|
+
# Provides filtering
|
4
6
|
class Versions
|
5
7
|
include Concord.new(:object)
|
6
8
|
|
@@ -9,21 +11,15 @@ module PaperTrailScrapbook
|
|
9
11
|
end
|
10
12
|
|
11
13
|
def related_content
|
12
|
-
unless object.respond_to?(:trailed_related_content)
|
13
|
-
return []
|
14
|
-
end
|
14
|
+
return [] unless object.respond_to?(:trailed_related_content)
|
15
15
|
|
16
16
|
object.trailed_related_content.compact.flat_map(&:versions)
|
17
17
|
end
|
18
18
|
|
19
19
|
def filtered(object_versions)
|
20
|
-
unless object.respond_to?(:version_filter)
|
21
|
-
return object_versions
|
22
|
-
end
|
20
|
+
return object_versions unless object.respond_to?(:version_filter)
|
23
21
|
|
24
22
|
object_versions.select { |v| object.version_filter(v) }
|
25
23
|
end
|
26
|
-
|
27
24
|
end
|
28
|
-
|
29
25
|
end
|
@@ -14,6 +14,7 @@ require 'paper_trail_scrapbook/secondary_chapter'
|
|
14
14
|
require 'paper_trail_scrapbook/user_journal'
|
15
15
|
require 'paper_trail_scrapbook/version'
|
16
16
|
require 'paper_trail_scrapbook/version_helpers'
|
17
|
+
require 'paper_trail_scrapbook/versions'
|
17
18
|
|
18
19
|
# Library namespace
|
19
20
|
#
|
@@ -15,32 +15,30 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.license = 'MIT'
|
16
16
|
|
17
17
|
gem.required_rubygems_version = '>= 1.3.6'
|
18
|
-
gem.required_ruby_version = '>= 2.
|
18
|
+
gem.required_ruby_version = '>= 2.6'
|
19
19
|
|
20
20
|
# Rails does not follow semver, makes breaking changes in minor versions.
|
21
21
|
gem.add_dependency 'activerecord'
|
22
22
|
gem.add_dependency 'adamantium'
|
23
23
|
gem.add_dependency 'concord'
|
24
|
-
gem.add_dependency 'paper_trail', ['>=
|
24
|
+
gem.add_dependency 'paper_trail', ['>= 11', '< 13']
|
25
25
|
|
26
26
|
gem.add_development_dependency 'ffaker', '~> 2.5'
|
27
27
|
gem.add_development_dependency 'rake', '~> 13.0.1'
|
28
28
|
|
29
29
|
# Why `railties`? Possibly used by `spec/dummy_app` boot up?
|
30
|
-
gem.add_development_dependency 'railties', '
|
30
|
+
gem.add_development_dependency 'railties', '>= 5.2.3'
|
31
31
|
|
32
32
|
gem.add_development_dependency 'codeclimate-test-reporter', '~> 1.0.7'
|
33
|
-
gem.add_development_dependency 'database_cleaner'
|
34
|
-
gem.add_development_dependency 'loofah'
|
35
|
-
gem.add_development_dependency '
|
36
|
-
gem.add_development_dependency '
|
37
|
-
gem.add_development_dependency 'pg', '= 0.18.4'
|
38
|
-
gem.add_development_dependency 'rspec-rails'
|
33
|
+
gem.add_development_dependency 'database_cleaner'
|
34
|
+
gem.add_development_dependency 'loofah'
|
35
|
+
gem.add_development_dependency 'pg'
|
36
|
+
gem.add_development_dependency 'rack', '>= 2.0.6'
|
39
37
|
gem.add_development_dependency 'rspec-jumpstart'
|
40
38
|
gem.add_development_dependency 'rspec_junit_formatter'
|
39
|
+
gem.add_development_dependency 'rspec-rails'
|
41
40
|
gem.add_development_dependency 'rubocop'
|
42
41
|
gem.add_development_dependency 'rubocop-rspec'
|
43
42
|
gem.add_development_dependency 'simplecov'
|
44
43
|
gem.add_development_dependency 'timecop', '~> 0.8.0'
|
45
|
-
gem.add_development_dependency 'rack', '>= 2.0.6'
|
46
44
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Fruit < ActiveRecord::Base
|
4
|
-
has_paper_trail class_name: 'JsonVersion' if ENV['
|
4
|
+
has_paper_trail versions: { class_name: 'JsonVersion' } if ENV['DATABASE_HOST'] == 'postgres' || JsonVersion.table_exists?
|
5
5
|
end
|