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 CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- soft_deletion (0.1.5)
4
+ soft_deletion (0.1.6)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -38,7 +38,7 @@ module SoftDeletion
38
38
  end
39
39
 
40
40
  def can_soft_delete?
41
- respond_to? :soft_delete!
41
+ klass.method_defined? :soft_delete!
42
42
  end
43
43
 
44
44
  def klass
@@ -1,3 +1,3 @@
1
1
  module SoftDeletion
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.6'
3
3
  end
@@ -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: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 5
10
- version: 0.1.5
9
+ - 6
10
+ version: 0.1.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Zendesk