paper_trail_viewer 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/{test.yml → tests.yml} +0 -0
- data/CHANGELOG.md +13 -0
- data/README.md +28 -10
- data/app/controllers/paper_trail_viewer/versions_controller.rb +5 -111
- data/app/views/paper_trail_viewer/viewer/index.html.erb +1 -1
- data/javascript/compiled.js +1 -1
- data/javascript/src/app.tsx +24 -13
- data/javascript/src/components/context_menu.tsx +61 -0
- data/javascript/src/components/index.ts +1 -0
- data/javascript/src/components/version_context_menu.tsx +110 -0
- data/javascript/src/components/versions_list.tsx +37 -47
- data/javascript/src/types.ts +9 -1
- data/lib/paper_trail_viewer/data_source/active_record.rb +13 -12
- data/lib/paper_trail_viewer/data_source/base.rb +87 -0
- data/lib/paper_trail_viewer/data_source/bigquery.rb +9 -8
- data/lib/paper_trail_viewer/query.rb +23 -0
- data/lib/paper_trail_viewer/rollback.rb +20 -0
- data/lib/paper_trail_viewer/version.rb +1 -1
- data/lib/paper_trail_viewer.rb +4 -0
- data/paper_trail_viewer.gemspec +0 -1
- data/spec/system/paper_trail_viewer_spec.rb +79 -64
- metadata +9 -5
@@ -14,101 +14,116 @@ describe PaperTrailViewer, versioning: true do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
context 'with changes' do
|
17
|
-
let(:reimu) { FactoryBot.create(:entity, name: 'Miko Hakurei Reimu', status: 'Highly Responsive to Prayers') }
|
18
|
-
let(:flanchan) { FactoryBot.create(:entity, name: 'Flandre Scarlet', status: 'The Embodiment of Scarlet Devil') }
|
19
|
-
let(:sakuya) { FactoryBot.create(:entity, name: 'Sakuya Izayoi', status: 'Flowering Night') }
|
20
|
-
let(:kyuu_hachi) { FactoryBot.create(:platform, name: 'PC-9801', status: 'SUGOI!!1!') }
|
17
|
+
let!(:reimu) { FactoryBot.create(:entity, name: 'Miko Hakurei Reimu', status: 'Highly Responsive to Prayers') }
|
18
|
+
let!(:flanchan) { FactoryBot.create(:entity, name: 'Flandre Scarlet', status: 'The Embodiment of Scarlet Devil') }
|
19
|
+
let!(:sakuya) { FactoryBot.create(:entity, name: 'Sakuya Izayoi', status: 'Flowering Night') }
|
20
|
+
let!(:kyuu_hachi) { FactoryBot.create(:platform, name: 'PC-9801', status: 'SUGOI!!1!') }
|
21
21
|
let!(:uinodouzu) { FactoryBot.create(:platform, name: 'Mikorusofto Uinodouzu', status: 'o-O') }
|
22
22
|
|
23
|
-
let!(:flanchan_id) { flanchan.id }
|
24
|
-
|
25
23
|
before do
|
26
|
-
|
27
|
-
reimu.update(
|
28
|
-
|
29
|
-
|
30
|
-
kyuu_hachi.
|
31
|
-
kyuu_hachi.destroy
|
32
|
-
uinodouzu
|
24
|
+
reimu.update!(name: 'Hakurei Reimu', status: 'Phantasmagoria of Dimensional Dream')
|
25
|
+
reimu.update!(status: 'Perfect Cherry Blossom')
|
26
|
+
flanchan.destroy!
|
27
|
+
kyuu_hachi.update!(status: 'Kimochi warui.')
|
28
|
+
kyuu_hachi.destroy!
|
33
29
|
end
|
34
30
|
|
35
31
|
describe 'index' do
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
within('table') do
|
47
|
-
expect(page).to have_content('Entity')
|
48
|
-
expect(page).to have_content('Platform')
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'orders changes with newest and highest id at the top' do
|
53
|
-
ids = PaperTrail::Version.pluck(:id)
|
54
|
-
expect(page).to have_content(/#{ids.sort.reverse.join('.+')}/m)
|
55
|
-
end
|
56
|
-
end
|
32
|
+
before { visit engine_urls.root_path }
|
33
|
+
|
34
|
+
it 'has all changes' do
|
35
|
+
expect(page).to have_selector('[data-ci-type="version-row"]', count: 10)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'has changes for all changed item types' do
|
39
|
+
within('table') do
|
40
|
+
expect(page).to have_content('Entity')
|
41
|
+
expect(page).to have_content('Platform')
|
57
42
|
end
|
58
43
|
end
|
59
44
|
|
45
|
+
it 'orders changes with newest and highest id at the top' do
|
46
|
+
ids = PaperTrail::Version.pluck(:id)
|
47
|
+
expect(page).to have_content(/#{ids.sort.reverse.join('.+')}/m)
|
48
|
+
end
|
49
|
+
|
60
50
|
context 'when getting changes for a specific type' do
|
61
|
-
|
62
|
-
before { visit engine_urls.root_path(item_type: 'Entity') }
|
51
|
+
before { visit engine_urls.root_path(item_type: 'Entity') }
|
63
52
|
|
64
|
-
|
65
|
-
|
66
|
-
end
|
53
|
+
it 'shows a subset of the changes' do
|
54
|
+
expect(page).to have_selector('[data-ci-type="version-row"]', count: 6)
|
67
55
|
end
|
68
56
|
end
|
69
57
|
|
70
58
|
context 'when getting changes for a specific record' do
|
71
|
-
|
72
|
-
before { visit engine_urls.root_path(item_type: 'Entity', item_id: reimu.id) }
|
59
|
+
before { visit engine_urls.root_path(item_type: 'Entity', item_id: reimu.id) }
|
73
60
|
|
74
|
-
|
75
|
-
|
76
|
-
end
|
61
|
+
it 'shows a subset of the changes' do
|
62
|
+
expect(page).to have_selector('[data-ci-type="version-row"]', count: 3)
|
77
63
|
end
|
78
64
|
end
|
79
65
|
end
|
80
66
|
|
67
|
+
describe 'tracking an item' do
|
68
|
+
it 'works' do
|
69
|
+
visit engine_urls.root_path
|
70
|
+
expect(page).to have_selector('[data-ci-type="version-row"]', count: 10)
|
71
|
+
|
72
|
+
open_reimu_actions_menu
|
73
|
+
click_on 'Track item'
|
74
|
+
|
75
|
+
expect(page).to have_selector('[data-ci-type="version-row"]', count: 3)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
81
79
|
describe 'rolling back changes' do
|
82
|
-
|
83
|
-
|
84
|
-
it 'rollbacks a newly-created record by deleting it' do
|
85
|
-
expect(Entity).to exist(reimu.id)
|
80
|
+
it 'can be done via the UI' do
|
81
|
+
visit engine_urls.root_path(item_type: 'Entity', item_id: reimu.id)
|
86
82
|
|
87
|
-
|
83
|
+
open_reimu_actions_menu
|
88
84
|
|
89
|
-
|
85
|
+
accept_confirm do # confirm that we really want to roll back
|
86
|
+
accept_alert do # accept alert saying that rollback happened
|
87
|
+
find('span', text: 'Roll back').click
|
90
88
|
end
|
89
|
+
end
|
91
90
|
|
92
|
-
|
93
|
-
|
94
|
-
expect(reimu.status).to eq 'Perfect Cherry Blossom'
|
91
|
+
expect(Entity.exists?(reimu.id)).to eq false
|
92
|
+
end
|
95
93
|
|
96
|
-
|
94
|
+
it 'rolls back a newly-created record by deleting it' do
|
95
|
+
expect(Entity).to exist(reimu.id)
|
97
96
|
|
98
|
-
|
99
|
-
expect(reimu.status).to eq 'Phantasmagoria of Dimensional Dream'
|
100
|
-
end
|
97
|
+
put engine_urls.version_path(reimu.versions.first)
|
101
98
|
|
102
|
-
|
103
|
-
|
99
|
+
expect(Entity).not_to exist(reimu.id)
|
100
|
+
end
|
104
101
|
|
105
|
-
|
102
|
+
it 'rolls back an edit by reverting to the previous state' do
|
103
|
+
reimu.reload
|
104
|
+
expect(reimu.status).to eq 'Perfect Cherry Blossom'
|
106
105
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
106
|
+
put engine_urls.version_path(reimu.versions.last)
|
107
|
+
|
108
|
+
reimu.reload
|
109
|
+
expect(reimu.status).to eq 'Phantasmagoria of Dimensional Dream'
|
111
110
|
end
|
111
|
+
|
112
|
+
it 'rolls back a delete by restoring the record' do
|
113
|
+
expect(Entity.exists?(flanchan.id)).to eq false
|
114
|
+
|
115
|
+
version = PaperTrail::Version.where(item_id: flanchan.id, item_type: 'Entity').last
|
116
|
+
put engine_urls.version_path(version)
|
117
|
+
|
118
|
+
found = Entity.find(flanchan.id)
|
119
|
+
expect(found.status).to eq 'The Embodiment of Scarlet Devil'
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def open_reimu_actions_menu
|
125
|
+
within("tr[data-ci-id='#{reimu.versions.find_by!(event: :create).id}']") do
|
126
|
+
find('[data-ci-type="version-action-button"]').click
|
112
127
|
end
|
113
128
|
end
|
114
129
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paper_trail_viewer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janosch Müller
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-03-
|
12
|
+
date: 2022-03-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: kaminari
|
@@ -174,12 +174,11 @@ dependencies:
|
|
174
174
|
description: Browse, view and revert changes to records when using Ruby on Rails and
|
175
175
|
the `paper_trail` gem.
|
176
176
|
email:
|
177
|
-
executables:
|
178
|
-
- setup
|
177
|
+
executables: []
|
179
178
|
extensions: []
|
180
179
|
extra_rdoc_files: []
|
181
180
|
files:
|
182
|
-
- ".github/workflows/
|
181
|
+
- ".github/workflows/tests.yml"
|
183
182
|
- ".gitignore"
|
184
183
|
- Appraisals
|
185
184
|
- CHANGELOG.md
|
@@ -200,18 +199,23 @@ files:
|
|
200
199
|
- javascript/src/app.tsx
|
201
200
|
- javascript/src/components/change_diff.tsx
|
202
201
|
- javascript/src/components/config_modal.tsx
|
202
|
+
- javascript/src/components/context_menu.tsx
|
203
203
|
- javascript/src/components/controls.tsx
|
204
204
|
- javascript/src/components/full_object_modal.tsx
|
205
205
|
- javascript/src/components/index.ts
|
206
206
|
- javascript/src/components/modal.tsx
|
207
207
|
- javascript/src/components/pagination.tsx
|
208
|
+
- javascript/src/components/version_context_menu.tsx
|
208
209
|
- javascript/src/components/versions_list.tsx
|
209
210
|
- javascript/src/index.ts
|
210
211
|
- javascript/src/types.ts
|
211
212
|
- lib/paper_trail_viewer.rb
|
212
213
|
- lib/paper_trail_viewer/data_source/active_record.rb
|
214
|
+
- lib/paper_trail_viewer/data_source/base.rb
|
213
215
|
- lib/paper_trail_viewer/data_source/bigquery.rb
|
214
216
|
- lib/paper_trail_viewer/engine.rb
|
217
|
+
- lib/paper_trail_viewer/query.rb
|
218
|
+
- lib/paper_trail_viewer/rollback.rb
|
215
219
|
- lib/paper_trail_viewer/version.rb
|
216
220
|
- package.json
|
217
221
|
- paper_trail_viewer.gemspec
|