destroyed_at 1.0.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 04939466ff647a0d0017648e6c952b9223b192d1
4
- data.tar.gz: f4063081197fd1557dfee1128da533be633eef54
3
+ metadata.gz: 7f228171fc8186eacb4a2b03091ac1da77801e98
4
+ data.tar.gz: 0e4ab1aadcc01078dd0b1decd2efaa2087131ee8
5
5
  SHA512:
6
- metadata.gz: 0aa141594c6795094f7090832560cd0e51ed8f77444a29161ee8e9df911c9637f06490c0e4a746fcfbdf9a754aa8a2a1431a8277bc49ce6e264304dce179cf86
7
- data.tar.gz: 9f03d073154ff339e9c56f920eef9580198ec3d3a45f577aec105bd6eea5e6cedd337f8d896d13ae26b5f8f4579ee982a42adee34383f83d444c87ad746e41d1
6
+ metadata.gz: b3c50322b6247e7baee90999128c42a8731812c4d37ba346e183f46c3dc54d6208740e5eacbf2c937a840f1e561d4ee5841cd5af7cae5824a7e5bf880e4a531f
7
+ data.tar.gz: 86f3b2fe4a8c15d9c5a1edb217161fdbe9377bfdcc970560d787dc6b63a7740e14330eee37a20f00b819d514253be378fd5a0dc7fce0652286b7aacf6e33ab6a
@@ -1,3 +1,9 @@
1
+ ## 2.0.0
2
+ * Associated models that do not include `DestroyedAt` will now be
3
+ **deleted** via `dependent: :destroy`. Previously, this was only the
4
+ behavior for child records; however, child records can now delete the
5
+ parent record (in accordance with default ActiveRecord behavior).
6
+
1
7
  ## 1.0.2
2
8
  * Fixes an issue in which
3
9
  `DestroyedAt::BelongsToAssociation#handle_dependency` was not deriving
@@ -6,7 +12,7 @@ an error for the wrong number of arguments. Thanks to
6
12
  [harmdewit](https://github.com/harmdewit) for catching this!
7
13
 
8
14
  ## 1.0.1
9
- * Fixes an issue with where the incorrect arguments were being passed
15
+ * Fixes an issue where the incorrect arguments were being passed
10
16
  from inside the `BelongsToAssociation` and `HasOneAssociation`, as
11
17
  reported by [anarchocurious](https://github.com/anarchocurious)
12
18
 
data/README.md CHANGED
@@ -71,14 +71,9 @@ user.destroyed_at
71
71
  ```
72
72
 
73
73
  #### Warning: Dependent relations with destroy ####
74
- Be careful when destroying parent relationships that have `dependent:
75
- :destroy`. If the child
76
- relationship does not also `include DestroyedAt`, then when you call
77
- `#destroy` on the parent instance, you will delete the child record,
78
- rather than simply marking it `destroyed_at`.
79
-
80
- The same goes for destroying through relations that omit `include
81
- DestroyedAt`, even if the parent and child models include the mixin.
74
+ Be careful when destroying models that have `dependent:
75
+ :destroy`. This will **delete**, not destroy, the associated model if
76
+ said model does not `include DestroyedAt`.
82
77
 
83
78
  ### Restoring ####
84
79
  When you'd like to "restore" a record, call the `#restore` method on
@@ -17,7 +17,8 @@ module DestroyedAt
17
17
  def self.destroy_target_of_association(owner, target)
18
18
  if target.respond_to?(:destroyed_at) && owner.respond_to?(:destroyed_at)
19
19
  target.destroy(owner.destroyed_at)
20
- elsif target.respond_to?(:destroyed_at)
20
+ else
21
+ # this will delete the target if DestroyedAt is not included.
21
22
  target.destroy
22
23
  end
23
24
  end
@@ -1,3 +1,3 @@
1
1
  module DestroyedAt
2
- VERSION = "1.0.2"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -196,13 +196,13 @@ describe 'non destroyed-at models' do
196
196
  end
197
197
 
198
198
  describe 'destroying a child that destroys its parent on destroy' do
199
- it 'does not destroy a parent record without DestroyedAt' do
199
+ it 'destroys the parent record' do
200
200
  parent = Person.create!
201
201
  child = DestructiveChild.create!(person: parent)
202
202
 
203
203
  child.destroy
204
204
 
205
- assert_equal(1, Person.count, 'Person must be one')
205
+ assert_equal(0, Person.count, 'Person must be one')
206
206
  assert_equal(0, DestructiveChild.count, 'DestructiveChild must be zero')
207
207
  end
208
208
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: destroyed_at
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Dupuis Jr.