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 +4 -4
- data/CHANGELOG.md +7 -1
- data/README.md +3 -8
- data/lib/destroyed_at.rb +2 -1
- data/lib/destroyed_at/version.rb +1 -1
- data/test/destroyed_at_test.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f228171fc8186eacb4a2b03091ac1da77801e98
|
4
|
+
data.tar.gz: 0e4ab1aadcc01078dd0b1decd2efaa2087131ee8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3c50322b6247e7baee90999128c42a8731812c4d37ba346e183f46c3dc54d6208740e5eacbf2c937a840f1e561d4ee5841cd5af7cae5824a7e5bf880e4a531f
|
7
|
+
data.tar.gz: 86f3b2fe4a8c15d9c5a1edb217161fdbe9377bfdcc970560d787dc6b63a7740e14330eee37a20f00b819d514253be378fd5a0dc7fce0652286b7aacf6e33ab6a
|
data/CHANGELOG.md
CHANGED
@@ -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
|
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
|
75
|
-
:destroy`.
|
76
|
-
|
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
|
data/lib/destroyed_at.rb
CHANGED
@@ -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
|
-
|
20
|
+
else
|
21
|
+
# this will delete the target if DestroyedAt is not included.
|
21
22
|
target.destroy
|
22
23
|
end
|
23
24
|
end
|
data/lib/destroyed_at/version.rb
CHANGED
data/test/destroyed_at_test.rb
CHANGED
@@ -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 '
|
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(
|
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
|