archival_record 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rubocop.yml +74 -0
  4. data/.rubocop_todo.yml +14 -0
  5. data/.travis.yml +23 -0
  6. data/Appraisals +18 -0
  7. data/CHANGELOG.md +96 -0
  8. data/Gemfile +2 -0
  9. data/Gemfile.lock +69 -0
  10. data/LICENSE +56 -0
  11. data/README.md +209 -0
  12. data/Rakefile +16 -0
  13. data/archival_record.gemspec +51 -0
  14. data/gemfiles/rails_5.0.gemfile +8 -0
  15. data/gemfiles/rails_5.1.gemfile +8 -0
  16. data/gemfiles/rails_5.2.gemfile +8 -0
  17. data/gemfiles/rails_6.0.gemfile +7 -0
  18. data/init.rb +3 -0
  19. data/lib/archival_record.rb +19 -0
  20. data/lib/archival_record/version.rb +5 -0
  21. data/lib/archival_record_core/archival_record.rb +164 -0
  22. data/lib/archival_record_core/archival_record_active_record_methods.rb +45 -0
  23. data/lib/archival_record_core/association_operation/archive.rb +21 -0
  24. data/lib/archival_record_core/association_operation/base.rb +54 -0
  25. data/lib/archival_record_core/association_operation/unarchive.rb +17 -0
  26. data/script/setup +9 -0
  27. data/test/ambiguous_table_test.rb +16 -0
  28. data/test/application_record_test.rb +20 -0
  29. data/test/associations_test.rb +104 -0
  30. data/test/basic_test.rb +66 -0
  31. data/test/callbacks_test.rb +41 -0
  32. data/test/column_test.rb +17 -0
  33. data/test/deep_nesting_test.rb +35 -0
  34. data/test/deprecated_warning_archival_test.rb +11 -0
  35. data/test/fixtures/another_polys_holder.rb +11 -0
  36. data/test/fixtures/application_record.rb +5 -0
  37. data/test/fixtures/application_record_row.rb +8 -0
  38. data/test/fixtures/archival.rb +19 -0
  39. data/test/fixtures/archival_grandkid.rb +10 -0
  40. data/test/fixtures/archival_kid.rb +11 -0
  41. data/test/fixtures/archival_table_name.rb +10 -0
  42. data/test/fixtures/callback_archival_4.rb +19 -0
  43. data/test/fixtures/callback_archival_5.rb +23 -0
  44. data/test/fixtures/deprecated_warning_archival.rb +9 -0
  45. data/test/fixtures/exploder.rb +10 -0
  46. data/test/fixtures/independent_archival.rb +11 -0
  47. data/test/fixtures/missing_archive_number.rb +7 -0
  48. data/test/fixtures/missing_archived_at.rb +7 -0
  49. data/test/fixtures/plain.rb +7 -0
  50. data/test/fixtures/poly.rb +11 -0
  51. data/test/fixtures/readonly_when_archived.rb +8 -0
  52. data/test/polymorphic_test.rb +50 -0
  53. data/test/readonly_when_archived_test.rb +24 -0
  54. data/test/relations_test.rb +63 -0
  55. data/test/responds_test.rb +15 -0
  56. data/test/schema.rb +96 -0
  57. data/test/scope_test.rb +92 -0
  58. data/test/test_helper.rb +91 -0
  59. data/test/through_association_test.rb +27 -0
  60. data/test/transaction_test.rb +31 -0
  61. metadata +254 -0
@@ -0,0 +1,27 @@
1
+ require_relative "test_helper"
2
+
3
+ class ThroughAssociationTest < ActiveSupport::TestCase
4
+
5
+ test "archive a through associated object whose 'bridge' is archival" do
6
+ archival = Archival.create!
7
+ bridge = archival.archival_kids.create!
8
+ through = bridge.archival_grandkids.create!
9
+ archival.archive!
10
+
11
+ assert archival.reload.archived?
12
+ assert bridge.reload.archived?
13
+ assert through.reload.archived?
14
+ end
15
+
16
+ # TODO: Make something like this pass
17
+ # test "archive a through associated object whose 'bridge' is not archival" do
18
+ # archival = Archival.create!
19
+ # bridge = archival.independent_archival_kids.create!
20
+ # through = bridge.archival_grandkids.create!
21
+ # archival.archive
22
+
23
+ # assert archival.reload.archived?
24
+ # assert through.reload.archived?
25
+ # end
26
+
27
+ end
@@ -0,0 +1,31 @@
1
+ require_relative "test_helper"
2
+ require "rr"
3
+
4
+ class TransactionTest < ActiveSupport::TestCase
5
+
6
+ test "archiving is transactional" do
7
+ archival = Archival.create!
8
+ exploder = archival.exploders.create!
9
+ any_instance_of(Exploder) do |canary|
10
+ stub(canary).archive! { raise "Rollback Imminent" }
11
+ end
12
+ archival.archive!
13
+
14
+ assert_not archival.archived?, "If this failed, you might be trying to test on a system that doesn't support nested transactions"
15
+ assert_not exploder.reload.archived?
16
+ end
17
+
18
+ test "unarchiving is transactional" do
19
+ archival = Archival.create!
20
+ exploder = archival.exploders.create!
21
+ any_instance_of(Exploder) do |canary|
22
+ stub(canary).unarchive! { raise "Rollback Imminent" }
23
+ end
24
+ archival.archive!
25
+ archival.unarchive!
26
+
27
+ assert archival.reload.archived?
28
+ assert exploder.reload.archived?
29
+ end
30
+
31
+ end
metadata ADDED
@@ -0,0 +1,254 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: archival_record
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Joel Meador
8
+ - Michael Kuehl
9
+ - Matthew Gordon
10
+ - Vojtech Salbaba
11
+ - David Jones
12
+ - Dave Woodward
13
+ - Miles Sterrett
14
+ - James Hill
15
+ - Maarten Claes
16
+ - Anthony Panozzo
17
+ - Aaron Milam
18
+ - Anton Rieder
19
+ - Josh Menden
20
+ - Sergey Gnuskov
21
+ - Elijah Miller
22
+ autorequire:
23
+ bindir: bin
24
+ cert_chain: []
25
+ date: 2020-08-03 00:00:00.000000000 Z
26
+ dependencies:
27
+ - !ruby/object:Gem::Dependency
28
+ name: activerecord
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '5.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '5.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: appraisal
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: database_cleaner
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.82.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.82.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: sqlite3
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: |
126
+ *Atomic archiving/unarchiving for ActiveRecord*
127
+
128
+ acts_as_paranoid and similar plugins/gems work on a record-by-record basis and make it difficult to restore records atomically (or archive them, for that matter).
129
+
130
+ Because ArchivalRecord's #archive! and #unarchive! methods are in transactions, and every archival record involved gets the same archive number upon archiving, you can easily restore or remove an entire set of records without having to worry about partial deletion or restoration.
131
+
132
+ Additionally, other plugins generally change how destroy/delete work. ArchivalRecord does not, and thus one can destroy records like normal.
133
+ email:
134
+ - joel.meador+archival_record@gmail.com
135
+ executables: []
136
+ extensions: []
137
+ extra_rdoc_files: []
138
+ files:
139
+ - ".gitignore"
140
+ - ".rubocop.yml"
141
+ - ".rubocop_todo.yml"
142
+ - ".travis.yml"
143
+ - Appraisals
144
+ - CHANGELOG.md
145
+ - Gemfile
146
+ - Gemfile.lock
147
+ - LICENSE
148
+ - README.md
149
+ - Rakefile
150
+ - archival_record.gemspec
151
+ - gemfiles/rails_5.0.gemfile
152
+ - gemfiles/rails_5.1.gemfile
153
+ - gemfiles/rails_5.2.gemfile
154
+ - gemfiles/rails_6.0.gemfile
155
+ - init.rb
156
+ - lib/archival_record.rb
157
+ - lib/archival_record/version.rb
158
+ - lib/archival_record_core/archival_record.rb
159
+ - lib/archival_record_core/archival_record_active_record_methods.rb
160
+ - lib/archival_record_core/association_operation/archive.rb
161
+ - lib/archival_record_core/association_operation/base.rb
162
+ - lib/archival_record_core/association_operation/unarchive.rb
163
+ - script/setup
164
+ - test/ambiguous_table_test.rb
165
+ - test/application_record_test.rb
166
+ - test/associations_test.rb
167
+ - test/basic_test.rb
168
+ - test/callbacks_test.rb
169
+ - test/column_test.rb
170
+ - test/deep_nesting_test.rb
171
+ - test/deprecated_warning_archival_test.rb
172
+ - test/fixtures/another_polys_holder.rb
173
+ - test/fixtures/application_record.rb
174
+ - test/fixtures/application_record_row.rb
175
+ - test/fixtures/archival.rb
176
+ - test/fixtures/archival_grandkid.rb
177
+ - test/fixtures/archival_kid.rb
178
+ - test/fixtures/archival_table_name.rb
179
+ - test/fixtures/callback_archival_4.rb
180
+ - test/fixtures/callback_archival_5.rb
181
+ - test/fixtures/deprecated_warning_archival.rb
182
+ - test/fixtures/exploder.rb
183
+ - test/fixtures/independent_archival.rb
184
+ - test/fixtures/missing_archive_number.rb
185
+ - test/fixtures/missing_archived_at.rb
186
+ - test/fixtures/plain.rb
187
+ - test/fixtures/poly.rb
188
+ - test/fixtures/readonly_when_archived.rb
189
+ - test/polymorphic_test.rb
190
+ - test/readonly_when_archived_test.rb
191
+ - test/relations_test.rb
192
+ - test/responds_test.rb
193
+ - test/schema.rb
194
+ - test/scope_test.rb
195
+ - test/test_helper.rb
196
+ - test/through_association_test.rb
197
+ - test/transaction_test.rb
198
+ homepage: http://github.com/janxious/archival_record
199
+ licenses: []
200
+ metadata: {}
201
+ post_install_message:
202
+ rdoc_options: []
203
+ require_paths:
204
+ - lib
205
+ required_ruby_version: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ version: '2.4'
210
+ required_rubygems_version: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - ">="
213
+ - !ruby/object:Gem::Version
214
+ version: '0'
215
+ requirements: []
216
+ rubygems_version: 3.1.2
217
+ signing_key:
218
+ specification_version: 4
219
+ summary: Atomic archiving/unarchiving for ActiveRecord
220
+ test_files:
221
+ - test/ambiguous_table_test.rb
222
+ - test/application_record_test.rb
223
+ - test/associations_test.rb
224
+ - test/basic_test.rb
225
+ - test/callbacks_test.rb
226
+ - test/column_test.rb
227
+ - test/deep_nesting_test.rb
228
+ - test/deprecated_warning_archival_test.rb
229
+ - test/fixtures/another_polys_holder.rb
230
+ - test/fixtures/application_record.rb
231
+ - test/fixtures/application_record_row.rb
232
+ - test/fixtures/archival.rb
233
+ - test/fixtures/archival_grandkid.rb
234
+ - test/fixtures/archival_kid.rb
235
+ - test/fixtures/archival_table_name.rb
236
+ - test/fixtures/callback_archival_4.rb
237
+ - test/fixtures/callback_archival_5.rb
238
+ - test/fixtures/deprecated_warning_archival.rb
239
+ - test/fixtures/exploder.rb
240
+ - test/fixtures/independent_archival.rb
241
+ - test/fixtures/missing_archive_number.rb
242
+ - test/fixtures/missing_archived_at.rb
243
+ - test/fixtures/plain.rb
244
+ - test/fixtures/poly.rb
245
+ - test/fixtures/readonly_when_archived.rb
246
+ - test/polymorphic_test.rb
247
+ - test/readonly_when_archived_test.rb
248
+ - test/relations_test.rb
249
+ - test/responds_test.rb
250
+ - test/schema.rb
251
+ - test/scope_test.rb
252
+ - test/test_helper.rb
253
+ - test/through_association_test.rb
254
+ - test/transaction_test.rb