acts_as_paranoid 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_helper.rb DELETED
@@ -1,541 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler"
4
- begin
5
- Bundler.load
6
- rescue Bundler::BundlerError => e
7
- warn e.message
8
- warn "Run `bundle install` to install missing gems"
9
- exit e.status_code
10
- end
11
-
12
- require "simplecov"
13
- SimpleCov.start do
14
- enable_coverage :branch
15
- end
16
-
17
- require "acts_as_paranoid"
18
- require "minitest/autorun"
19
-
20
- # Silence deprecation halfway through the test
21
- I18n.enforce_available_locales = true
22
-
23
- ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
24
- ActiveRecord::Schema.verbose = false
25
-
26
- # rubocop:disable Metrics/AbcSize
27
- # rubocop:disable Metrics/MethodLength
28
- def setup_db
29
- ActiveRecord::Schema.define(version: 1) do # rubocop:disable Metrics/BlockLength
30
- create_table :paranoid_times do |t|
31
- t.string :name
32
- t.datetime :deleted_at
33
- t.integer :paranoid_belongs_dependant_id
34
- t.integer :not_paranoid_id
35
-
36
- timestamps t
37
- end
38
-
39
- create_table :paranoid_booleans do |t|
40
- t.string :name
41
- t.boolean :is_deleted
42
- t.integer :paranoid_time_id
43
- t.integer :paranoid_with_counter_caches_count
44
- t.integer :custom_counter_cache
45
- timestamps t
46
- end
47
-
48
- create_table :paranoid_strings do |t|
49
- t.string :name
50
- t.string :deleted
51
- end
52
-
53
- create_table :not_paranoids do |t|
54
- t.string :name
55
- t.integer :paranoid_time_id
56
-
57
- timestamps t
58
- end
59
-
60
- create_table :has_one_not_paranoids do |t|
61
- t.string :name
62
- t.integer :paranoid_time_id
63
-
64
- timestamps t
65
- end
66
-
67
- create_table :paranoid_has_many_dependants do |t|
68
- t.string :name
69
- t.datetime :deleted_at
70
- t.integer :paranoid_time_id
71
- t.string :paranoid_time_polymorphic_with_deleted_type
72
- t.integer :paranoid_belongs_dependant_id
73
-
74
- timestamps t
75
- end
76
-
77
- create_table :paranoid_belongs_dependants do |t|
78
- t.string :name
79
- t.datetime :deleted_at
80
-
81
- timestamps t
82
- end
83
-
84
- create_table :paranoid_has_one_dependants do |t|
85
- t.string :name
86
- t.datetime :deleted_at
87
- t.integer :paranoid_boolean_id
88
-
89
- timestamps t
90
- end
91
-
92
- create_table :paranoid_with_callbacks do |t|
93
- t.string :name
94
- t.datetime :deleted_at
95
-
96
- timestamps t
97
- end
98
-
99
- create_table :paranoid_destroy_companies do |t|
100
- t.string :name
101
- t.datetime :deleted_at
102
-
103
- timestamps t
104
- end
105
-
106
- create_table :paranoid_delete_companies do |t|
107
- t.string :name
108
- t.datetime :deleted_at
109
-
110
- timestamps t
111
- end
112
-
113
- create_table :paranoid_products do |t|
114
- t.integer :paranoid_destroy_company_id
115
- t.integer :paranoid_delete_company_id
116
- t.string :name
117
- t.datetime :deleted_at
118
-
119
- timestamps t
120
- end
121
-
122
- create_table :super_paranoids do |t|
123
- t.string :type
124
- t.references :has_many_inherited_super_paranoidz,
125
- index: { name: "index__sp_id_on_has_many_isp" }
126
- t.datetime :deleted_at
127
-
128
- timestamps t
129
- end
130
-
131
- create_table :has_many_inherited_super_paranoidzs do |t|
132
- t.references :super_paranoidz, index: { name: "index_has_many_isp_on_sp_id" }
133
- t.datetime :deleted_at
134
-
135
- timestamps t
136
- end
137
-
138
- create_table :paranoid_many_many_parent_lefts do |t|
139
- t.string :name
140
- timestamps t
141
- end
142
-
143
- create_table :paranoid_many_many_parent_rights do |t|
144
- t.string :name
145
- timestamps t
146
- end
147
-
148
- create_table :paranoid_many_many_children do |t|
149
- t.integer :paranoid_many_many_parent_left_id
150
- t.integer :paranoid_many_many_parent_right_id
151
- t.datetime :deleted_at
152
- timestamps t
153
- end
154
-
155
- create_table :paranoid_with_scoped_validations do |t|
156
- t.string :name
157
- t.string :category
158
- t.datetime :deleted_at
159
- timestamps t
160
- end
161
-
162
- create_table :paranoid_forests do |t|
163
- t.string :name
164
- t.boolean :rainforest
165
- t.datetime :deleted_at
166
-
167
- timestamps t
168
- end
169
-
170
- create_table :paranoid_trees do |t|
171
- t.integer :paranoid_forest_id
172
- t.string :name
173
- t.datetime :deleted_at
174
-
175
- timestamps t
176
- end
177
-
178
- create_table :paranoid_polygons do |t|
179
- t.integer :sides
180
- t.datetime :deleted_at
181
-
182
- timestamps t
183
- end
184
-
185
- create_table :paranoid_androids do |t|
186
- t.datetime :deleted_at
187
- end
188
-
189
- create_table :paranoid_sections do |t|
190
- t.integer :paranoid_time_id
191
- t.integer :paranoid_thing_id
192
- t.string :paranoid_thing_type
193
- t.datetime :deleted_at
194
- end
195
-
196
- create_table :paranoid_boolean_not_nullables do |t|
197
- t.string :name
198
- t.boolean :deleted, :boolean, null: false, default: false
199
- end
200
-
201
- create_table :paranoid_belongs_to_polymorphics do |t|
202
- t.string :name
203
- t.string :parent_type
204
- t.integer :parent_id
205
- t.datetime :deleted_at
206
-
207
- timestamps t
208
- end
209
-
210
- create_table :not_paranoid_has_many_as_parents do |t|
211
- t.string :name
212
-
213
- timestamps t
214
- end
215
-
216
- create_table :paranoid_has_many_as_parents do |t|
217
- t.string :name
218
- t.datetime :deleted_at
219
-
220
- timestamps t
221
- end
222
-
223
- create_table :paranoid_no_double_tap_destroys_fullies do |t|
224
- t.datetime :deleted_at
225
- end
226
-
227
- create_table :paranoid_with_counter_caches do |t|
228
- t.string :name
229
- t.datetime :deleted_at
230
- t.integer :paranoid_boolean_id
231
-
232
- timestamps t
233
- end
234
- end
235
- end
236
- # rubocop:enable Metrics/AbcSize
237
- # rubocop:enable Metrics/MethodLength
238
-
239
- def timestamps(table)
240
- table.column :created_at, :timestamp, null: false
241
- table.column :updated_at, :timestamp, null: false
242
- end
243
-
244
- def teardown_db
245
- ActiveRecord::Base.connection.data_sources.each do |table|
246
- ActiveRecord::Base.connection.drop_table(table)
247
- end
248
- end
249
-
250
- class ParanoidTime < ActiveRecord::Base
251
- acts_as_paranoid
252
-
253
- validates_uniqueness_of :name
254
-
255
- has_many :paranoid_has_many_dependants, dependent: :destroy
256
- has_many :paranoid_booleans, dependent: :destroy
257
- has_many :not_paranoids, dependent: :delete_all
258
- has_many :paranoid_sections, dependent: :destroy
259
-
260
- has_one :has_one_not_paranoid, dependent: :destroy
261
-
262
- belongs_to :not_paranoid, dependent: :destroy
263
- end
264
-
265
- class ParanoidBoolean < ActiveRecord::Base
266
- acts_as_paranoid column_type: "boolean", column: "is_deleted"
267
- validates_as_paranoid
268
- validates_uniqueness_of_without_deleted :name
269
-
270
- belongs_to :paranoid_time
271
- has_one :paranoid_has_one_dependant, dependent: :destroy
272
- has_many :paranoid_with_counter_cache, dependent: :destroy
273
- has_many :paranoid_with_custom_counter_cache, dependent: :destroy
274
- end
275
-
276
- class ParanoidString < ActiveRecord::Base
277
- acts_as_paranoid column_type: "string", column: "deleted", deleted_value: "dead"
278
- end
279
-
280
- class NotParanoid < ActiveRecord::Base
281
- end
282
-
283
- class ParanoidNoDoubleTapDestroysFully < ActiveRecord::Base
284
- acts_as_paranoid double_tap_destroys_fully: false
285
- end
286
-
287
- class HasOneNotParanoid < ActiveRecord::Base
288
- belongs_to :paranoid_time, with_deleted: true
289
- end
290
-
291
- class DoubleHasOneNotParanoid < HasOneNotParanoid
292
- belongs_to :paranoid_time, with_deleted: true
293
- begin
294
- verbose = $VERBOSE
295
- $VERBOSE = false
296
- belongs_to :paranoid_time, with_deleted: true
297
- ensure
298
- $VERBOSE = verbose
299
- end
300
- end
301
-
302
- class ParanoidWithCounterCache < ActiveRecord::Base
303
- acts_as_paranoid
304
- belongs_to :paranoid_boolean, counter_cache: true
305
- end
306
-
307
- class ParanoidWithCustomCounterCache < ActiveRecord::Base
308
- self.table_name = "paranoid_with_counter_caches"
309
-
310
- acts_as_paranoid
311
- belongs_to :paranoid_boolean, counter_cache: :custom_counter_cache
312
- end
313
-
314
- class ParanoidWithCounterCacheOnOptionalBelognsTo < ActiveRecord::Base
315
- self.table_name = "paranoid_with_counter_caches"
316
-
317
- acts_as_paranoid
318
- if ActiveRecord::VERSION::MAJOR < 5
319
- belongs_to :paranoid_boolean, counter_cache: true, required: false
320
- else
321
- belongs_to :paranoid_boolean, counter_cache: true, optional: true
322
- end
323
- end
324
-
325
- class ParanoidHasManyDependant < ActiveRecord::Base
326
- acts_as_paranoid
327
- belongs_to :paranoid_time
328
- belongs_to :paranoid_time_with_scope,
329
- -> { where(name: "hello").includes(:not_paranoid) },
330
- class_name: "ParanoidTime", foreign_key: :paranoid_time_id
331
- belongs_to :paranoid_time_with_deleted, class_name: "ParanoidTime",
332
- foreign_key: :paranoid_time_id, with_deleted: true
333
- belongs_to :paranoid_time_with_scope_with_deleted,
334
- -> { where(name: "hello").includes(:not_paranoid) },
335
- class_name: "ParanoidTime", foreign_key: :paranoid_time_id, with_deleted: true
336
- belongs_to :paranoid_time_polymorphic_with_deleted, class_name: "ParanoidTime",
337
- foreign_key: :paranoid_time_id,
338
- polymorphic: true, with_deleted: true
339
-
340
- belongs_to :paranoid_belongs_dependant, dependent: :destroy
341
- end
342
-
343
- class ParanoidBelongsDependant < ActiveRecord::Base
344
- acts_as_paranoid
345
-
346
- has_many :paranoid_has_many_dependants
347
- end
348
-
349
- class ParanoidHasOneDependant < ActiveRecord::Base
350
- acts_as_paranoid
351
-
352
- belongs_to :paranoid_boolean
353
- end
354
-
355
- class ParanoidWithCallback < ActiveRecord::Base
356
- acts_as_paranoid
357
-
358
- attr_accessor :called_before_destroy, :called_after_destroy,
359
- :called_after_commit_on_destroy, :called_before_recover,
360
- :called_after_recover
361
-
362
- before_destroy :call_me_before_destroy
363
- after_destroy :call_me_after_destroy
364
-
365
- after_commit :call_me_after_commit_on_destroy, on: :destroy
366
-
367
- before_recover :call_me_before_recover
368
- after_recover :call_me_after_recover
369
-
370
- def initialize(*attrs)
371
- @called_before_destroy = @called_after_destroy = @called_after_commit_on_destroy = false
372
- super(*attrs)
373
- end
374
-
375
- def call_me_before_destroy
376
- @called_before_destroy = true
377
- end
378
-
379
- def call_me_after_destroy
380
- @called_after_destroy = true
381
- end
382
-
383
- def call_me_after_commit_on_destroy
384
- @called_after_commit_on_destroy = true
385
- end
386
-
387
- def call_me_before_recover
388
- @called_before_recover = true
389
- end
390
-
391
- def call_me_after_recover
392
- @called_after_recover = true
393
- end
394
- end
395
-
396
- class ParanoidDestroyCompany < ActiveRecord::Base
397
- acts_as_paranoid
398
- validates :name, presence: true
399
- has_many :paranoid_products, dependent: :destroy
400
- end
401
-
402
- class ParanoidDeleteCompany < ActiveRecord::Base
403
- acts_as_paranoid
404
- validates :name, presence: true
405
- has_many :paranoid_products, dependent: :delete_all
406
- end
407
-
408
- class ParanoidProduct < ActiveRecord::Base
409
- acts_as_paranoid
410
- belongs_to :paranoid_destroy_company
411
- belongs_to :paranoid_delete_company
412
- validates_presence_of :name
413
- end
414
-
415
- class SuperParanoid < ActiveRecord::Base
416
- acts_as_paranoid
417
- belongs_to :has_many_inherited_super_paranoidz
418
- end
419
-
420
- class HasManyInheritedSuperParanoidz < ActiveRecord::Base
421
- has_many :super_paranoidz, class_name: "InheritedParanoid", dependent: :destroy
422
- end
423
-
424
- class InheritedParanoid < SuperParanoid
425
- acts_as_paranoid
426
- end
427
-
428
- class ParanoidManyManyParentLeft < ActiveRecord::Base
429
- has_many :paranoid_many_many_children
430
- has_many :paranoid_many_many_parent_rights, through: :paranoid_many_many_children
431
- end
432
-
433
- class ParanoidManyManyParentRight < ActiveRecord::Base
434
- has_many :paranoid_many_many_children
435
- has_many :paranoid_many_many_parent_lefts, through: :paranoid_many_many_children
436
- end
437
-
438
- class ParanoidManyManyChild < ActiveRecord::Base
439
- acts_as_paranoid
440
- belongs_to :paranoid_many_many_parent_left
441
- belongs_to :paranoid_many_many_parent_right
442
- end
443
-
444
- class ParanoidWithScopedValidation < ActiveRecord::Base
445
- acts_as_paranoid
446
- validates_uniqueness_of :name, scope: :category
447
- end
448
-
449
- class ParanoidBelongsToPolymorphic < ActiveRecord::Base
450
- acts_as_paranoid
451
- belongs_to :parent, polymorphic: true, with_deleted: true
452
- end
453
-
454
- class NotParanoidHasManyAsParent < ActiveRecord::Base
455
- has_many :paranoid_belongs_to_polymorphics, as: :parent, dependent: :destroy
456
- end
457
-
458
- class ParanoidHasManyAsParent < ActiveRecord::Base
459
- acts_as_paranoid
460
- has_many :paranoid_belongs_to_polymorphics, as: :parent, dependent: :destroy
461
- end
462
-
463
- class ParanoidBaseTest < ActiveSupport::TestCase
464
- def setup
465
- setup_db
466
-
467
- ["paranoid", "really paranoid", "extremely paranoid"].each do |name|
468
- ParanoidTime.create! name: name
469
- ParanoidBoolean.create! name: name
470
- end
471
-
472
- ParanoidString.create! name: "strings can be paranoid"
473
- NotParanoid.create! name: "no paranoid goals"
474
- ParanoidWithCallback.create! name: "paranoid with callbacks"
475
- end
476
-
477
- def teardown
478
- teardown_db
479
- end
480
-
481
- def assert_empty(collection)
482
- assert(collection.respond_to?(:empty?) && collection.empty?)
483
- end
484
-
485
- def assert_paranoid_deletion(model)
486
- row = find_row(model)
487
- assert_not_nil row, "#{model.class} entirely deleted"
488
- assert_not_nil row["deleted_at"], "Deleted at not set"
489
- end
490
-
491
- def assert_non_paranoid_deletion(model)
492
- row = find_row(model)
493
- assert_nil row, "#{model.class} still exists"
494
- end
495
-
496
- def find_row(model)
497
- sql = "select deleted_at from #{model.class.table_name} where id = #{model.id}"
498
- # puts sql here if you want to debug
499
- model.class.connection.select_one(sql)
500
- end
501
- end
502
-
503
- class ParanoidForest < ActiveRecord::Base
504
- acts_as_paranoid
505
-
506
- ActiveRecord::Base.logger = Logger.new(StringIO.new)
507
-
508
- scope :rainforest, -> { where(rainforest: true) }
509
-
510
- has_many :paranoid_trees, dependent: :destroy
511
- end
512
-
513
- class ParanoidTree < ActiveRecord::Base
514
- acts_as_paranoid
515
- belongs_to :paranoid_forest
516
- validates_presence_of :name
517
- end
518
-
519
- class ParanoidPolygon < ActiveRecord::Base
520
- acts_as_paranoid
521
- default_scope { where("sides = ?", 3) }
522
- end
523
-
524
- class ParanoidAndroid < ActiveRecord::Base
525
- acts_as_paranoid
526
- end
527
-
528
- class ParanoidSection < ActiveRecord::Base
529
- acts_as_paranoid
530
- belongs_to :paranoid_time
531
- belongs_to :paranoid_thing, polymorphic: true, dependent: :destroy
532
- end
533
-
534
- class ParanoidBooleanNotNullable < ActiveRecord::Base
535
- acts_as_paranoid column: "deleted", column_type: "boolean", allow_nulls: false
536
- end
537
-
538
- class ParanoidWithExplicitTableNameAfterMacro < ActiveRecord::Base
539
- acts_as_paranoid
540
- self.table_name = "explicit_table"
541
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "test_helper"
4
-
5
- class InheritanceTest < ParanoidBaseTest
6
- def test_destroy_dependents_with_inheritance
7
- has_many_inherited_super_paranoidz = HasManyInheritedSuperParanoidz.new
8
- has_many_inherited_super_paranoidz.save
9
- has_many_inherited_super_paranoidz.super_paranoidz.create
10
- assert_nothing_raised { has_many_inherited_super_paranoidz.destroy }
11
- end
12
-
13
- def test_class_instance_variables_are_inherited
14
- assert_nothing_raised { InheritedParanoid.paranoid_column }
15
- end
16
- end
@@ -1,125 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "test_helper"
4
-
5
- class RelationsTest < ParanoidBaseTest
6
- def setup
7
- setup_db
8
-
9
- @paranoid_forest_1 = ParanoidForest.create! name: "ParanoidForest #1"
10
- @paranoid_forest_2 = ParanoidForest.create! name: "ParanoidForest #2", rainforest: true
11
- @paranoid_forest_3 = ParanoidForest.create! name: "ParanoidForest #3", rainforest: true
12
-
13
- assert_equal 3, ParanoidForest.count
14
- assert_equal 2, ParanoidForest.rainforest.count
15
-
16
- @paranoid_forest_1.paranoid_trees.create! name: "ParanoidTree #1"
17
- @paranoid_forest_1.paranoid_trees.create! name: "ParanoidTree #2"
18
- @paranoid_forest_2.paranoid_trees.create! name: "ParanoidTree #3"
19
- @paranoid_forest_2.paranoid_trees.create! name: "ParanoidTree #4"
20
-
21
- assert_equal 4, ParanoidTree.count
22
- end
23
-
24
- def test_filtering_with_scopes
25
- assert_equal 2, ParanoidForest.rainforest.with_deleted.count
26
- assert_equal 2, ParanoidForest.with_deleted.rainforest.count
27
-
28
- assert_equal 0, ParanoidForest.rainforest.only_deleted.count
29
- assert_equal 0, ParanoidForest.only_deleted.rainforest.count
30
-
31
- ParanoidForest.rainforest.first.destroy
32
- assert_equal 1, ParanoidForest.rainforest.count
33
-
34
- assert_equal 2, ParanoidForest.rainforest.with_deleted.count
35
- assert_equal 2, ParanoidForest.with_deleted.rainforest.count
36
-
37
- assert_equal 1, ParanoidForest.rainforest.only_deleted.count
38
- assert_equal 1, ParanoidForest.only_deleted.rainforest.count
39
- end
40
-
41
- def test_associations_filtered_by_with_deleted
42
- assert_equal 2, @paranoid_forest_1.paranoid_trees.with_deleted.count
43
- assert_equal 2, @paranoid_forest_2.paranoid_trees.with_deleted.count
44
-
45
- @paranoid_forest_1.paranoid_trees.first.destroy
46
- assert_equal 1, @paranoid_forest_1.paranoid_trees.count
47
- assert_equal 2, @paranoid_forest_1.paranoid_trees.with_deleted.count
48
- assert_equal 4, ParanoidTree.with_deleted.count
49
-
50
- @paranoid_forest_2.paranoid_trees.first.destroy
51
- assert_equal 1, @paranoid_forest_2.paranoid_trees.count
52
- assert_equal 2, @paranoid_forest_2.paranoid_trees.with_deleted.count
53
- assert_equal 4, ParanoidTree.with_deleted.count
54
-
55
- @paranoid_forest_1.paranoid_trees.first.destroy
56
- assert_equal 0, @paranoid_forest_1.paranoid_trees.count
57
- assert_equal 2, @paranoid_forest_1.paranoid_trees.with_deleted.count
58
- assert_equal 4, ParanoidTree.with_deleted.count
59
- end
60
-
61
- def test_associations_filtered_by_only_deleted
62
- assert_equal 0, @paranoid_forest_1.paranoid_trees.only_deleted.count
63
- assert_equal 0, @paranoid_forest_2.paranoid_trees.only_deleted.count
64
-
65
- @paranoid_forest_1.paranoid_trees.first.destroy
66
- assert_equal 1, @paranoid_forest_1.paranoid_trees.only_deleted.count
67
- assert_equal 1, ParanoidTree.only_deleted.count
68
-
69
- @paranoid_forest_2.paranoid_trees.first.destroy
70
- assert_equal 1, @paranoid_forest_2.paranoid_trees.only_deleted.count
71
- assert_equal 2, ParanoidTree.only_deleted.count
72
-
73
- @paranoid_forest_1.paranoid_trees.first.destroy
74
- assert_equal 2, @paranoid_forest_1.paranoid_trees.only_deleted.count
75
- assert_equal 3, ParanoidTree.only_deleted.count
76
- end
77
-
78
- def test_fake_removal_through_relation
79
- # destroy: through a relation.
80
- ParanoidForest.rainforest.destroy(@paranoid_forest_3.id)
81
- assert_equal 1, ParanoidForest.rainforest.count
82
- assert_equal 2, ParanoidForest.rainforest.with_deleted.count
83
- assert_equal 1, ParanoidForest.rainforest.only_deleted.count
84
-
85
- # destroy_all: through a relation
86
- @paranoid_forest_2.paranoid_trees.order(:id).destroy_all
87
- assert_equal 0, @paranoid_forest_2.paranoid_trees.count
88
- assert_equal 2, @paranoid_forest_2.paranoid_trees.with_deleted.count
89
- end
90
-
91
- def test_real_removal_through_relation_with_destroy_bang
92
- # Relation.destroy!: aliased to delete
93
- ParanoidForest.rainforest.destroy!(@paranoid_forest_3)
94
- assert_equal 1, ParanoidForest.rainforest.count
95
- assert_equal 1, ParanoidForest.rainforest.with_deleted.count
96
- assert_equal 0, ParanoidForest.rainforest.only_deleted.count
97
- end
98
-
99
- def test_two_step_real_removal_through_relation_with_destroy
100
- # destroy: two-step through a relation
101
- paranoid_tree = @paranoid_forest_1.paranoid_trees.first
102
- @paranoid_forest_1.paranoid_trees.order(:id).destroy(paranoid_tree.id)
103
- @paranoid_forest_1.paranoid_trees.only_deleted.destroy(paranoid_tree.id)
104
- assert_equal 1, @paranoid_forest_1.paranoid_trees.count
105
- assert_equal 1, @paranoid_forest_1.paranoid_trees.with_deleted.count
106
- assert_equal 0, @paranoid_forest_1.paranoid_trees.only_deleted.count
107
- end
108
-
109
- def test_two_step_real_removal_through_relation_with_destroy_all
110
- # destroy_all: two-step through a relation
111
- @paranoid_forest_1.paranoid_trees.order(:id).destroy_all
112
- @paranoid_forest_1.paranoid_trees.only_deleted.destroy_all
113
- assert_equal 0, @paranoid_forest_1.paranoid_trees.count
114
- assert_equal 0, @paranoid_forest_1.paranoid_trees.with_deleted.count
115
- assert_equal 0, @paranoid_forest_1.paranoid_trees.only_deleted.count
116
- end
117
-
118
- def test_real_removal_through_relation_with_delete_all_bang
119
- # delete_all!: through a relation
120
- @paranoid_forest_2.paranoid_trees.order(:id).delete_all!
121
- assert_equal 0, @paranoid_forest_2.paranoid_trees.count
122
- assert_equal 0, @paranoid_forest_2.paranoid_trees.with_deleted.count
123
- assert_equal 0, @paranoid_forest_2.paranoid_trees.only_deleted.count
124
- end
125
- end