paper_trail_scrapbook 0.1.16 → 0.1.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +5 -2
- data/Changelog.md +12 -1
- data/Gemfile.lock +19 -16
- data/README.md +57 -11
- data/lib/paper_trail_scrapbook.rb +1 -0
- data/lib/paper_trail_scrapbook/changes.rb +1 -1
- data/lib/paper_trail_scrapbook/chapter.rb +1 -1
- data/lib/paper_trail_scrapbook/journal_entry.rb +1 -1
- data/lib/paper_trail_scrapbook/life_history.rb +2 -9
- data/lib/paper_trail_scrapbook/user_journal.rb +1 -1
- data/lib/paper_trail_scrapbook/version.rb +1 -1
- data/lib/paper_trail_scrapbook/versions.rb +29 -0
- data/paper_trail_scrapbook.gemspec +7 -6
- data/pkg/paper_trail_scrapbook-0.1.18.gem +0 -0
- data/pkg/paper_trail_scrapbook-0.1.19.gem +0 -0
- data/spec/paper_trail_scrapbook/journal_entry_spec.rb +28 -0
- data/spec/paper_trail_scrapbook/versions_spec.rb +94 -0
- data/spec/paper_trail_scrapbook_spec.rb +9 -1
- metadata +35 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3ea6a987eb4b121ef35faa696cbab0e1280f82c9c5c50994cedbcfa3fd2a161
|
4
|
+
data.tar.gz: 750cd326b91c05264c536476836cc64f612ef8e82e043be3f4cdd9fe5139a493
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34b3c0af6ab002f7e4c076d6f490a6e9546e8c4b91b5c27e9679b6e669a072a00159a8cfebaf47b56601c714a26959f9692bd0baa75a92a039ff46a2584d9345
|
7
|
+
data.tar.gz: 84652d9b2f8fbf4c5a2d234fb6db4cea7dd4b50f8321aacd049caed5db0a2f968107b5dc328ed3bac855235f9902a81b83becd9357af3cf973da399d6990a606
|
data/.circleci/config.yml
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
defaults: &defaults
|
2
2
|
docker:
|
3
3
|
- image: circleci/ruby:2.5.0-node-browsers
|
4
|
+
environment:
|
5
|
+
PGUSER: circleci
|
4
6
|
- image: circleci/postgres:9.5-alpine
|
5
7
|
environment:
|
6
8
|
POSTGRES_USER: circleci
|
@@ -21,10 +23,11 @@ jobs:
|
|
21
23
|
command: |
|
22
24
|
echo 'export BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")' >> $BASH_ENV
|
23
25
|
source $BASH_ENV
|
24
|
-
gem install bundler
|
26
|
+
gem install bundler -v $BUNDLER_VERSION
|
25
27
|
- run:
|
26
28
|
name: Bundle Install
|
27
|
-
command:
|
29
|
+
command:
|
30
|
+
bundle check || bundle install
|
28
31
|
- save_cache:
|
29
32
|
key: paper_trail_scrapbook-{{ checksum "Gemfile.lock" }}
|
30
33
|
paths:
|
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,11 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
paper_trail_scrapbook (0.1.
|
4
|
+
paper_trail_scrapbook (0.1.21)
|
5
5
|
activerecord
|
6
6
|
adamantium
|
7
7
|
concord
|
8
|
-
paper_trail (>= 5.2, <=
|
8
|
+
paper_trail (>= 5.2, <= 11.1.0)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
@@ -51,7 +51,7 @@ GEM
|
|
51
51
|
adamantium (~> 0.2.0)
|
52
52
|
equalizer (~> 0.0.9)
|
53
53
|
concurrent-ruby (1.1.5)
|
54
|
-
crass (1.0.
|
54
|
+
crass (1.0.5)
|
55
55
|
database_cleaner (1.6.2)
|
56
56
|
diff-lcs (1.3)
|
57
57
|
docile (1.1.5)
|
@@ -61,8 +61,8 @@ GEM
|
|
61
61
|
i18n (1.7.0)
|
62
62
|
concurrent-ruby (~> 1.0)
|
63
63
|
ice_nine (0.11.2)
|
64
|
-
json (2.1
|
65
|
-
loofah (2.
|
64
|
+
json (2.3.1)
|
65
|
+
loofah (2.3.1)
|
66
66
|
crass (~> 1.0.2)
|
67
67
|
nokogiri (>= 1.5.9)
|
68
68
|
memoizable (0.4.2)
|
@@ -98,18 +98,18 @@ GEM
|
|
98
98
|
mutant-rspec (0.8.14)
|
99
99
|
mutant (~> 0.8.14)
|
100
100
|
rspec-core (>= 3.4.0, < 3.7.0)
|
101
|
-
nokogiri (1.10.
|
101
|
+
nokogiri (1.10.8)
|
102
102
|
mini_portile2 (~> 2.4.0)
|
103
|
-
paper_trail (10.
|
104
|
-
activerecord (>= 4.2
|
103
|
+
paper_trail (10.3.1)
|
104
|
+
activerecord (>= 4.2)
|
105
105
|
request_store (~> 1.1)
|
106
106
|
parallel (1.12.1)
|
107
107
|
parser (2.4.0.2)
|
108
108
|
ast (~> 2.3)
|
109
|
-
pg (
|
109
|
+
pg (1.2.3)
|
110
110
|
powerpack (0.1.1)
|
111
111
|
procto (0.0.3)
|
112
|
-
rack (2.
|
112
|
+
rack (2.2.3)
|
113
113
|
rack-test (1.1.0)
|
114
114
|
rack (>= 1.0, < 3)
|
115
115
|
rails-dom-testing (2.0.3)
|
@@ -124,15 +124,16 @@ GEM
|
|
124
124
|
rake (>= 0.8.7)
|
125
125
|
thor (>= 0.19.0, < 2.0)
|
126
126
|
rainbow (3.0.0)
|
127
|
-
rake (
|
127
|
+
rake (13.0.1)
|
128
128
|
regexp_parser (0.4.9)
|
129
|
-
request_store (1.
|
129
|
+
request_store (1.5.0)
|
130
130
|
rack (>= 1.4)
|
131
131
|
rspec-core (3.6.0)
|
132
132
|
rspec-support (~> 3.6.0)
|
133
133
|
rspec-expectations (3.6.0)
|
134
134
|
diff-lcs (>= 1.2.0, < 2.0)
|
135
135
|
rspec-support (~> 3.6.0)
|
136
|
+
rspec-jumpstart (1.1.2)
|
136
137
|
rspec-mocks (3.6.0)
|
137
138
|
diff-lcs (>= 1.2.0, < 2.0)
|
138
139
|
rspec-support (~> 3.6.0)
|
@@ -179,19 +180,21 @@ GEM
|
|
179
180
|
|
180
181
|
PLATFORMS
|
181
182
|
ruby
|
183
|
+
x86_64-darwin-20
|
182
184
|
|
183
185
|
DEPENDENCIES
|
184
186
|
codeclimate-test-reporter (~> 1.0.7)
|
185
187
|
database_cleaner (~> 1.2)
|
186
188
|
ffaker (~> 2.5)
|
187
|
-
loofah (~> 2.
|
189
|
+
loofah (~> 2.3.1)
|
188
190
|
mutant
|
189
191
|
mutant-rspec
|
190
192
|
paper_trail_scrapbook!
|
191
|
-
pg (=
|
193
|
+
pg (= 1.2.3)
|
192
194
|
rack (>= 2.0.6)
|
193
195
|
railties (= 5.2.3)
|
194
|
-
rake (~>
|
196
|
+
rake (~> 13.0.1)
|
197
|
+
rspec-jumpstart
|
195
198
|
rspec-rails
|
196
199
|
rspec_junit_formatter
|
197
200
|
rubocop
|
@@ -200,4 +203,4 @@ DEPENDENCIES
|
|
200
203
|
timecop (~> 0.8.0)
|
201
204
|
|
202
205
|
BUNDLED WITH
|
203
|
-
2.
|
206
|
+
2.2.2
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Paper Trail Scrapbook
|
2
2
|
|
3
|
-
[![CircleCI](https://circleci.com/gh/
|
3
|
+
[![CircleCI](https://circleci.com/gh/hintmedia/paper_trail_scrapbook/tree/master.svg?style=svg)](https://circleci.com/gh/tjchambers/paper_trail_scrapbook/tree/master)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/paper_trail_scrapbook.svg)](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.
|
@@ -16,9 +16,9 @@ Add PaperTrailScrapBook to your `Gemfile`.
|
|
16
16
|
### Configuration
|
17
17
|
|
18
18
|
This gem is dependent on [PaperTrail](https://github.com/paper-trail-gem/paper_trail),
|
19
|
-
and specifically, on the `object_changes` column in the `PaperTrail::Version`
|
19
|
+
and specifically, on the `object_changes` column in the `PaperTrail::Version`
|
20
20
|
table. If your `PaperTrail` installation does not include this column, you can
|
21
|
-
add it manually, or re-
|
21
|
+
add it manually, or re-run the `PaperTrail` generator:
|
22
22
|
|
23
23
|
```
|
24
24
|
bundle exec rake generate paper_trail:install --with_changes
|
@@ -78,12 +78,12 @@ widget = Widget.find 42
|
|
78
78
|
text = PaperTrailScrapbook::LifeHistory.new(widget).story
|
79
79
|
# On Wednesday, 07 Jun 2017 at 2:37 PM, Rob Owens created the following Widget information:
|
80
80
|
# • email: Tim@example.com
|
81
|
-
# • name: Tim's Widget
|
81
|
+
# • name: Tim's Widget
|
82
82
|
# • built: true
|
83
83
|
# • created_by: Rob Owens[1742]
|
84
84
|
# • provider: RedCharge[3113]
|
85
85
|
# • cost: 29612.0
|
86
|
-
# • discounted_price: 29612.0
|
86
|
+
# • discounted_price: 29612.0
|
87
87
|
```
|
88
88
|
|
89
89
|
If desired, you can implement a `trailed_related_content` method in your model
|
@@ -118,18 +118,64 @@ text = PaperTrailScrapbook::LifeHistory.new(widget).story
|
|
118
118
|
#
|
119
119
|
# On Wednesday, 07 Jun 2017 at 2:37 PM, Rob Owens created the following Widget information:
|
120
120
|
# • email: Tim@example.com
|
121
|
-
# • name: Tim's Widget
|
121
|
+
# • name: Tim's Widget
|
122
122
|
# • manufacturer: WidgetsAreUs[411]
|
123
123
|
# •: 1234
|
124
|
-
#
|
124
|
+
#
|
125
125
|
# On Thursday, 23 Oct 2017 at 7:55 AM PDT, Rob Owens updated Manufacturer[411]:
|
126
126
|
# • name: WidgetsRUs
|
127
|
-
#
|
127
|
+
#
|
128
128
|
# On Friday, 24 Oct 2017 at 10:10 AM PDT, Rob Owens created the following Attachment[212] information:
|
129
129
|
# • name: Electromagnet
|
130
130
|
# • widget: Tim's Widget[1234]
|
131
131
|
# •: 212
|
132
|
-
#
|
132
|
+
#
|
133
|
+
```
|
134
|
+
|
135
|
+
`PaperTrailScrapbook` also implements a `version_filter` hook to provide a flexible way to filter which versions appear in a object's history. For example, if we only wanted our `Widget` class to include history for its manufacturer after the widget was created, we might implement `Widget#version_filter` like this:
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
class Widget < ApplicationRecord
|
139
|
+
has_paper_trail
|
140
|
+
|
141
|
+
def trailed_related_content
|
142
|
+
attachments | [manufacturer]
|
143
|
+
end
|
144
|
+
|
145
|
+
def version_filter(version)
|
146
|
+
case version.item_type
|
147
|
+
when 'Manufacturer'
|
148
|
+
if version.created_at < created_at
|
149
|
+
return nil
|
150
|
+
end
|
151
|
+
end
|
152
|
+
version
|
153
|
+
end
|
154
|
+
|
155
|
+
...
|
156
|
+
```
|
157
|
+
|
158
|
+
Then, the above history would be:
|
159
|
+
|
160
|
+
```ruby
|
161
|
+
widget = Widget.find 42
|
162
|
+
|
163
|
+
text = PaperTrailScrapbook::LifeHistory.new(widget).story
|
164
|
+
|
165
|
+
# On Wednesday, 07 Jun 2017 at 2:37 PM, Rob Owens created the following Widget information:
|
166
|
+
# • email: Tim@example.com
|
167
|
+
# • name: Tim's Widget
|
168
|
+
# • manufacturer: WidgetsAreUs[411]
|
169
|
+
# •: 1234
|
170
|
+
#
|
171
|
+
# On Thursday, 23 Oct 2017 at 7:55 AM PDT, Rob Owens updated Manufacturer[411]:
|
172
|
+
# • name: WidgetsRUs
|
173
|
+
#
|
174
|
+
# On Friday, 24 Oct 2017 at 10:10 AM PDT, Rob Owens created the following Attachment[212] information:
|
175
|
+
# • name: Electromagnet
|
176
|
+
# • widget: Tim's Widget[1234]
|
177
|
+
# •: 212
|
178
|
+
#
|
133
179
|
```
|
134
180
|
|
135
181
|
### User Journal
|
@@ -199,7 +245,7 @@ text = PaperTrailScrapbook::UserJournal.new(who, start: 1.month.ago, end: Time.n
|
|
199
245
|
|
200
246
|
## Problems
|
201
247
|
|
202
|
-
Please use GitHub's [issue tracker](http://github.com/
|
248
|
+
Please use GitHub's [issue tracker](http://github.com/hintmedia/paper_trail_scrapbook/issues).
|
203
249
|
|
204
250
|
|
205
251
|
## Contributors
|
@@ -215,7 +261,7 @@ possible.
|
|
215
261
|
|
216
262
|
## Intellectual Property
|
217
263
|
|
218
|
-
Copyright (c) 2017
|
264
|
+
Copyright (c) 2017 Hint Media, Inc.
|
219
265
|
Released under the MIT licence.
|
220
266
|
|
221
267
|
|
@@ -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
|
#
|
@@ -5,7 +5,7 @@ require_relative 'version_helpers'
|
|
5
5
|
module PaperTrailScrapbook
|
6
6
|
# Class Chapter provides single version history analysis
|
7
7
|
#
|
8
|
-
# @author Timothy Chambers <tim@
|
8
|
+
# @author Timothy Chambers <tim@hint.io>
|
9
9
|
#
|
10
10
|
class Chapter
|
11
11
|
include Concord.new(:version)
|
@@ -5,7 +5,7 @@ require_relative 'version_helpers'
|
|
5
5
|
module PaperTrailScrapbook
|
6
6
|
# Class JournalEntry provides single version history analysis
|
7
7
|
#
|
8
|
-
# @author Jason Dinsmore <jason@
|
8
|
+
# @author Jason Dinsmore <jason@hint.io>
|
9
9
|
#
|
10
10
|
class JournalEntry
|
11
11
|
include Concord.new(:version)
|
@@ -3,19 +3,12 @@
|
|
3
3
|
module PaperTrailScrapbook
|
4
4
|
# Class LifeHistory provides Full multi version history
|
5
5
|
#
|
6
|
-
# @author Timothy Chambers <tim@
|
6
|
+
# @author Timothy Chambers <tim@hint.io>
|
7
7
|
#
|
8
8
|
class LifeHistory
|
9
9
|
def initialize(object)
|
10
10
|
@object = object
|
11
|
-
@versions = object.versions
|
12
|
-
if object.respond_to?(:trailed_related_content)
|
13
|
-
object.trailed_related_content.compact.each do |trc|
|
14
|
-
@versions |= trc.versions
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
@versions = @versions.sort_by(&:created_at)
|
11
|
+
@versions = Versions.new(object).versions
|
19
12
|
end
|
20
13
|
|
21
14
|
# Retries textual historical analysis of versions
|
@@ -4,7 +4,7 @@ module PaperTrailScrapbook
|
|
4
4
|
# Class UserJournal provides history for a user, optionally scoped by
|
5
5
|
# object class and/or date range
|
6
6
|
#
|
7
|
-
# @author Jason Dinsmore <jason@
|
7
|
+
# @author Jason Dinsmore <jason@hint.io>
|
8
8
|
#
|
9
9
|
class UserJournal
|
10
10
|
include Adamantium::Flat
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PaperTrailScrapbook
|
4
|
+
class Versions
|
5
|
+
include Concord.new(:object)
|
6
|
+
|
7
|
+
def versions
|
8
|
+
filtered(object.versions | related_content).sort_by(&:created_at)
|
9
|
+
end
|
10
|
+
|
11
|
+
def related_content
|
12
|
+
unless object.respond_to?(:trailed_related_content)
|
13
|
+
return []
|
14
|
+
end
|
15
|
+
|
16
|
+
object.trailed_related_content.compact.flat_map(&:versions)
|
17
|
+
end
|
18
|
+
|
19
|
+
def filtered(object_versions)
|
20
|
+
unless object.respond_to?(:version_filter)
|
21
|
+
return object_versions
|
22
|
+
end
|
23
|
+
|
24
|
+
object_versions.select { |v| object.version_filter(v) }
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -9,9 +9,9 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.summary = 'Paper Trail Scrapbook'
|
10
10
|
gem.description = "Human Readable Change Log for Paper Trail'd data"
|
11
11
|
gem.authors = ['Timothy Chambers']
|
12
|
-
gem.email = 'tim@
|
12
|
+
gem.email = 'tim@hint.io'
|
13
13
|
gem.files = `git ls-files`.split("\n")
|
14
|
-
gem.homepage = 'https://github.com/
|
14
|
+
gem.homepage = 'https://github.com/hintmedia/paper_trail_scrapbook'
|
15
15
|
gem.license = 'MIT'
|
16
16
|
|
17
17
|
gem.required_rubygems_version = '>= 1.3.6'
|
@@ -21,21 +21,22 @@ Gem::Specification.new do |gem|
|
|
21
21
|
gem.add_dependency 'activerecord'
|
22
22
|
gem.add_dependency 'adamantium'
|
23
23
|
gem.add_dependency 'concord'
|
24
|
-
gem.add_dependency 'paper_trail', ['>= 5.2', '<=
|
24
|
+
gem.add_dependency 'paper_trail', ['>= 5.2', '<= 11.1.0']
|
25
25
|
|
26
26
|
gem.add_development_dependency 'ffaker', '~> 2.5'
|
27
|
-
gem.add_development_dependency 'rake', '~>
|
27
|
+
gem.add_development_dependency 'rake', '~> 13.0.1'
|
28
28
|
|
29
29
|
# Why `railties`? Possibly used by `spec/dummy_app` boot up?
|
30
30
|
gem.add_development_dependency 'railties', '= 5.2.3'
|
31
31
|
|
32
32
|
gem.add_development_dependency 'codeclimate-test-reporter', '~> 1.0.7'
|
33
33
|
gem.add_development_dependency 'database_cleaner', '~> 1.2'
|
34
|
-
gem.add_development_dependency 'loofah', '~> 2.
|
34
|
+
gem.add_development_dependency 'loofah', '~> 2.3.1'
|
35
35
|
gem.add_development_dependency 'mutant'
|
36
36
|
gem.add_development_dependency 'mutant-rspec'
|
37
|
-
gem.add_development_dependency 'pg', '=
|
37
|
+
gem.add_development_dependency 'pg', '= 1.2.3'
|
38
38
|
gem.add_development_dependency 'rspec-rails'
|
39
|
+
gem.add_development_dependency 'rspec-jumpstart'
|
39
40
|
gem.add_development_dependency 'rspec_junit_formatter'
|
40
41
|
gem.add_development_dependency 'rubocop'
|
41
42
|
gem.add_development_dependency 'rubocop-rspec'
|
Binary file
|
Binary file
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require './lib/paper_trail_scrapbook/journal_entry'
|
5
|
+
|
6
|
+
RSpec.describe PaperTrailScrapbook::JournalEntry do
|
7
|
+
let(:person) { Person.create!(name: 'The Tim Man') }
|
8
|
+
let(:book) { Book.create!(title: 'How the Grinch stole Xmas') }
|
9
|
+
let(:version) do
|
10
|
+
OpenStruct.new(event: 'create',
|
11
|
+
item_type: 'Book',
|
12
|
+
item_id: book.id,
|
13
|
+
created_at: whenn,
|
14
|
+
version_author: person.id)
|
15
|
+
end
|
16
|
+
let(:subject) { described_class.new(version) }
|
17
|
+
let(:whenn) { Time.parse('2019-12-16 12:01:29 -0800') }
|
18
|
+
|
19
|
+
describe '#story' do
|
20
|
+
it 'story' do
|
21
|
+
result = subject.story
|
22
|
+
|
23
|
+
expect(result).to eql('On Monday, 16 Dec 2019 at 12:01 PM, '\
|
24
|
+
"created Book[#{book.id}]:\n")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module PaperTrailScrapbook
|
6
|
+
::RSpec.describe Versions do
|
7
|
+
before do
|
8
|
+
PaperTrailScrapbook.config.whodunnit_class = Person
|
9
|
+
PaperTrail.request.whodunnit = person.id
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:book) do
|
13
|
+
Book.new(title: 'How the Grinch stole Xmas').tap(&:save!)
|
14
|
+
end
|
15
|
+
let(:person) { Person.create(name: 'The Tim Man') }
|
16
|
+
let!(:authorship) do
|
17
|
+
Authorship.new(book: book, author: person).tap(&:save!)
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:object) { described_class.new(book) }
|
21
|
+
|
22
|
+
describe '#versions' do
|
23
|
+
it 'versions' do
|
24
|
+
book.update!(title: 'New Title')
|
25
|
+
|
26
|
+
result = object.versions
|
27
|
+
|
28
|
+
expect(result).to eql(book.versions.to_a)
|
29
|
+
expect(result.size).to equal(2)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#related_content' do
|
34
|
+
it 'related_content returns nothing if no related content' do
|
35
|
+
result = object.related_content
|
36
|
+
|
37
|
+
expect(result).to eql([])
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'returns related content' do
|
41
|
+
allow(book).to receive(:respond_to?)
|
42
|
+
.with(:trailed_related_content).and_return(true)
|
43
|
+
allow(book).to receive(:respond_to?)
|
44
|
+
.with(:trailed_related_content, true).and_return(true)
|
45
|
+
allow(book).to receive(:trailed_related_content) do
|
46
|
+
book.authorships
|
47
|
+
end
|
48
|
+
|
49
|
+
result = object.related_content
|
50
|
+
|
51
|
+
expect(result).to eql(authorship.versions.to_a)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#filtered' do
|
56
|
+
it 'returns versions if no filter' do
|
57
|
+
result = object.filtered(book.versions.to_a)
|
58
|
+
|
59
|
+
expect(result).to eql(book.versions.to_a)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'returns filtered versions if filter' do
|
63
|
+
allow(book).to receive(:respond_to?)
|
64
|
+
.with(:version_filter, true).and_return(true)
|
65
|
+
allow(book).to receive(:respond_to?)
|
66
|
+
.with(:version_filter).and_return(true)
|
67
|
+
allow(book).to receive(:version_filter) do |_version|
|
68
|
+
nil
|
69
|
+
end
|
70
|
+
|
71
|
+
result = object.filtered(book.versions.to_a)
|
72
|
+
|
73
|
+
expect(result).to eql([])
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'returns filtered versions if filter' do
|
77
|
+
book.update!(title: 'New Title')
|
78
|
+
|
79
|
+
allow(book).to receive(:respond_to?).with(:version_filter, true).and_return(true)
|
80
|
+
allow(book).to receive(:respond_to?).with(:version_filter).and_return(true)
|
81
|
+
allow(book).to receive(:version_filter) do |version|
|
82
|
+
if version.event.eql?('update')
|
83
|
+
version
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
result = object.filtered(book.versions)
|
88
|
+
|
89
|
+
expect(result).to eql([book.versions.last])
|
90
|
+
expect(result.size).not_to eql(book.versions.size)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -2,5 +2,13 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
|
5
|
+
RSpec.describe PaperTrailScrapbook do
|
6
|
+
describe '.config' do
|
7
|
+
it 'sets the @config ivar' do
|
8
|
+
described_class.config
|
9
|
+
|
10
|
+
expect(described_class.instance_variable_get(:@config))
|
11
|
+
.to equal(PaperTrailScrapbook::Config.instance)
|
12
|
+
end
|
13
|
+
end
|
6
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paper_trail_scrapbook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timothy Chambers
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -61,7 +61,7 @@ dependencies:
|
|
61
61
|
version: '5.2'
|
62
62
|
- - "<="
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version:
|
64
|
+
version: 11.1.0
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -71,7 +71,7 @@ dependencies:
|
|
71
71
|
version: '5.2'
|
72
72
|
- - "<="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
74
|
+
version: 11.1.0
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: ffaker
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,14 +92,14 @@ dependencies:
|
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
95
|
+
version: 13.0.1
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
102
|
+
version: 13.0.1
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: railties
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,14 +148,14 @@ dependencies:
|
|
148
148
|
requirements:
|
149
149
|
- - "~>"
|
150
150
|
- !ruby/object:Gem::Version
|
151
|
-
version: 2.
|
151
|
+
version: 2.3.1
|
152
152
|
type: :development
|
153
153
|
prerelease: false
|
154
154
|
version_requirements: !ruby/object:Gem::Requirement
|
155
155
|
requirements:
|
156
156
|
- - "~>"
|
157
157
|
- !ruby/object:Gem::Version
|
158
|
-
version: 2.
|
158
|
+
version: 2.3.1
|
159
159
|
- !ruby/object:Gem::Dependency
|
160
160
|
name: mutant
|
161
161
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,14 +190,14 @@ dependencies:
|
|
190
190
|
requirements:
|
191
191
|
- - '='
|
192
192
|
- !ruby/object:Gem::Version
|
193
|
-
version:
|
193
|
+
version: 1.2.3
|
194
194
|
type: :development
|
195
195
|
prerelease: false
|
196
196
|
version_requirements: !ruby/object:Gem::Requirement
|
197
197
|
requirements:
|
198
198
|
- - '='
|
199
199
|
- !ruby/object:Gem::Version
|
200
|
-
version:
|
200
|
+
version: 1.2.3
|
201
201
|
- !ruby/object:Gem::Dependency
|
202
202
|
name: rspec-rails
|
203
203
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,6 +212,20 @@ dependencies:
|
|
212
212
|
- - ">="
|
213
213
|
- !ruby/object:Gem::Version
|
214
214
|
version: '0'
|
215
|
+
- !ruby/object:Gem::Dependency
|
216
|
+
name: rspec-jumpstart
|
217
|
+
requirement: !ruby/object:Gem::Requirement
|
218
|
+
requirements:
|
219
|
+
- - ">="
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '0'
|
222
|
+
type: :development
|
223
|
+
prerelease: false
|
224
|
+
version_requirements: !ruby/object:Gem::Requirement
|
225
|
+
requirements:
|
226
|
+
- - ">="
|
227
|
+
- !ruby/object:Gem::Version
|
228
|
+
version: '0'
|
215
229
|
- !ruby/object:Gem::Dependency
|
216
230
|
name: rspec_junit_formatter
|
217
231
|
requirement: !ruby/object:Gem::Requirement
|
@@ -297,7 +311,7 @@ dependencies:
|
|
297
311
|
- !ruby/object:Gem::Version
|
298
312
|
version: 2.0.6
|
299
313
|
description: Human Readable Change Log for Paper Trail'd data
|
300
|
-
email: tim@
|
314
|
+
email: tim@hint.io
|
301
315
|
executables: []
|
302
316
|
extensions: []
|
303
317
|
extra_rdoc_files: []
|
@@ -326,9 +340,12 @@ files:
|
|
326
340
|
- lib/paper_trail_scrapbook/user_journal.rb
|
327
341
|
- lib/paper_trail_scrapbook/version.rb
|
328
342
|
- lib/paper_trail_scrapbook/version_helpers.rb
|
343
|
+
- lib/paper_trail_scrapbook/versions.rb
|
329
344
|
- log/mutant/pts.log
|
330
345
|
- paper_trail_scrapbook.gemspec
|
331
346
|
- pkg/paper_trail_scrapbook-0.0.2.gem
|
347
|
+
- pkg/paper_trail_scrapbook-0.1.18.gem
|
348
|
+
- pkg/paper_trail_scrapbook-0.1.19.gem
|
332
349
|
- pkg/paper_trail_scrapbook-0.1.6.gem
|
333
350
|
- pkg/paper_trail_scrapbook-0.1.7.gem
|
334
351
|
- spec/dummy_app/Rakefile
|
@@ -405,18 +422,20 @@ files:
|
|
405
422
|
- spec/paper_trail_scrapbook/changes_spec.rb
|
406
423
|
- spec/paper_trail_scrapbook/chapter_spec.rb
|
407
424
|
- spec/paper_trail_scrapbook/config_spec.rb
|
425
|
+
- spec/paper_trail_scrapbook/journal_entry_spec.rb
|
408
426
|
- spec/paper_trail_scrapbook/life_history_spec.rb
|
409
427
|
- spec/paper_trail_scrapbook/secondary_chapter_spec.rb
|
410
428
|
- spec/paper_trail_scrapbook/user_journal_spec.rb
|
411
429
|
- spec/paper_trail_scrapbook/version_helpers_spec.rb
|
412
430
|
- spec/paper_trail_scrapbook/version_spec.rb
|
431
|
+
- spec/paper_trail_scrapbook/versions_spec.rb
|
413
432
|
- spec/paper_trail_scrapbook_spec.rb
|
414
433
|
- spec/spec_helper.rb
|
415
|
-
homepage: https://github.com/
|
434
|
+
homepage: https://github.com/hintmedia/paper_trail_scrapbook
|
416
435
|
licenses:
|
417
436
|
- MIT
|
418
437
|
metadata: {}
|
419
|
-
post_install_message:
|
438
|
+
post_install_message:
|
420
439
|
rdoc_options: []
|
421
440
|
require_paths:
|
422
441
|
- lib
|
@@ -431,8 +450,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
431
450
|
- !ruby/object:Gem::Version
|
432
451
|
version: 1.3.6
|
433
452
|
requirements: []
|
434
|
-
rubygems_version: 3.
|
435
|
-
signing_key:
|
453
|
+
rubygems_version: 3.2.2
|
454
|
+
signing_key:
|
436
455
|
specification_version: 4
|
437
456
|
summary: Paper Trail Scrapbook
|
438
457
|
test_files: []
|