soft_deletion 0.1.5 → 0.1.6
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.
- data/Gemfile.lock +1 -1
- data/lib/soft_deletion/dependency.rb +1 -1
- data/lib/soft_deletion/version.rb +1 -1
- data/test/soft_deletion_test.rb +33 -0
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/test/soft_deletion_test.rb
CHANGED
@@ -78,6 +78,18 @@ class OriginalCategory < ActiveRecord::Base
|
|
78
78
|
include SoftDeletion
|
79
79
|
end
|
80
80
|
|
81
|
+
# Has many destroyable association
|
82
|
+
class DACategory < ActiveRecord::Base
|
83
|
+
silent_set_table_name 'categories'
|
84
|
+
include SoftDeletion
|
85
|
+
has_many :destroyable_forums, :dependent => :destroy, :foreign_key => :category_id
|
86
|
+
end
|
87
|
+
|
88
|
+
# Forum that isn't soft deletable for association checing
|
89
|
+
class DestroyableForum < ActiveRecord::Base
|
90
|
+
silent_set_table_name 'forums'
|
91
|
+
end
|
92
|
+
|
81
93
|
def clear_callbacks(model, callback)
|
82
94
|
if ActiveRecord::VERSION::MAJOR > 2
|
83
95
|
model.define_callbacks callback
|
@@ -193,6 +205,27 @@ class SoftDeletionTest < ActiveSupport::TestCase
|
|
193
205
|
successfully_bulk_soft_deletes
|
194
206
|
end
|
195
207
|
|
208
|
+
context "with dependent association that doesn't have soft deletion" do
|
209
|
+
setup do
|
210
|
+
@category = DACategory.create!
|
211
|
+
@forum = @category.destroyable_forums.create!
|
212
|
+
end
|
213
|
+
|
214
|
+
context 'successfully soft deleted' do
|
215
|
+
setup do
|
216
|
+
@category.soft_delete!
|
217
|
+
end
|
218
|
+
|
219
|
+
should 'mark itself as deleted' do
|
220
|
+
assert_deleted @category
|
221
|
+
end
|
222
|
+
|
223
|
+
should 'not destroy dependent association' do
|
224
|
+
assert DestroyableForum.exists?(@forum.id)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
196
229
|
context 'with dependent has_many associations' do
|
197
230
|
setup do
|
198
231
|
@category = Category.create!
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soft_deletion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Zendesk
|