destroyed_at 1.0.1 → 1.0.2
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.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/CHANGELOG.md +7 -0
- data/lib/destroyed_at/belongs_to_association.rb +1 -1
- data/lib/destroyed_at/version.rb +1 -1
- data/test/destroyed_at_test.rb +13 -1
- data/test/test_helper.rb +6 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04939466ff647a0d0017648e6c952b9223b192d1
|
4
|
+
data.tar.gz: f4063081197fd1557dfee1128da533be633eef54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aa141594c6795094f7090832560cd0e51ed8f77444a29161ee8e9df911c9637f06490c0e4a746fcfbdf9a754aa8a2a1431a8277bc49ce6e264304dce179cf86
|
7
|
+
data.tar.gz: 9f03d073154ff339e9c56f920eef9580198ec3d3a45f577aec105bd6eea5e6cedd337f8d896d13ae26b5f8f4579ee982a42adee34383f83d444c87ad746e41d1
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.6
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 1.0.2
|
2
|
+
* Fixes an issue in which
|
3
|
+
`DestroyedAt::BelongsToAssociation#handle_dependency` was not deriving
|
4
|
+
the action from the `options` hash, but was using `method` and raising
|
5
|
+
an error for the wrong number of arguments. Thanks to
|
6
|
+
[harmdewit](https://github.com/harmdewit) for catching this!
|
7
|
+
|
1
8
|
## 1.0.1
|
2
9
|
* Fixes an issue with where the incorrect arguments were being passed
|
3
10
|
from inside the `BelongsToAssociation` and `HasOneAssociation`, as
|
data/lib/destroyed_at/version.rb
CHANGED
data/test/destroyed_at_test.rb
CHANGED
@@ -186,7 +186,7 @@ end
|
|
186
186
|
describe 'non destroyed-at models' do
|
187
187
|
it 'can destroy has_on dependants' do
|
188
188
|
person = Person.create!
|
189
|
-
|
189
|
+
person.create_pet!
|
190
190
|
|
191
191
|
person.destroy
|
192
192
|
|
@@ -194,3 +194,15 @@ describe 'non destroyed-at models' do
|
|
194
194
|
assert_equal(0, Pet.count, 'Pet must be zero')
|
195
195
|
end
|
196
196
|
end
|
197
|
+
|
198
|
+
describe 'destroying a child that destroys its parent on destroy' do
|
199
|
+
it 'does not destroy a parent record without DestroyedAt' do
|
200
|
+
parent = Person.create!
|
201
|
+
child = DestructiveChild.create!(person: parent)
|
202
|
+
|
203
|
+
child.destroy
|
204
|
+
|
205
|
+
assert_equal(1, Person.count, 'Person must be one')
|
206
|
+
assert_equal(0, DestructiveChild.count, 'DestructiveChild must be zero')
|
207
|
+
end
|
208
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -33,6 +33,7 @@ ActiveRecord::Base.connection.execute(%{CREATE TABLE categories (id INTEGER PRIM
|
|
33
33
|
ActiveRecord::Base.connection.execute(%{CREATE TABLE categorizations (id INTEGER PRIMARY KEY, category_id INTEGER, post_id INTEGER);})
|
34
34
|
ActiveRecord::Base.connection.execute(%{CREATE TABLE comments (id INTEGER PRIMARY KEY, commenter_id INTEGER, post_id INTEGER, destroyed_at DATETIME);})
|
35
35
|
ActiveRecord::Base.connection.execute(%{CREATE TABLE commenters (id INTEGER PRIMARY KEY, destroyed_at DATETIME);})
|
36
|
+
ActiveRecord::Base.connection.execute(%{CREATE TABLE destructive_children (id INTEGER PRIMARY KEY, person_id INTEGER, destroyed_at DATETIME);})
|
36
37
|
ActiveRecord::Base.connection.execute(%{CREATE TABLE images (id INTEGER PRIMARY KEY, post_id INTEGER);})
|
37
38
|
ActiveRecord::Base.connection.execute(%{CREATE TABLE posts (id INTEGER PRIMARY KEY, author_id INTEGER, destroyed_at DATETIME);})
|
38
39
|
ActiveRecord::Base.connection.execute(%{CREATE TABLE people (id INTEGER PRIMARY KEY);})
|
@@ -44,6 +45,7 @@ class Author < ActiveRecord::Base
|
|
44
45
|
end
|
45
46
|
|
46
47
|
class Person < ActiveRecord::Base
|
48
|
+
has_many :destructive_children
|
47
49
|
has_one :pet, dependent: :destroy
|
48
50
|
end
|
49
51
|
|
@@ -78,6 +80,10 @@ class Commenter < ActiveRecord::Base
|
|
78
80
|
has_many :posts, through: :comments
|
79
81
|
end
|
80
82
|
|
83
|
+
class DestructiveChild < ActiveRecord::Base
|
84
|
+
belongs_to :person, dependent: :destroy
|
85
|
+
end
|
86
|
+
|
81
87
|
class Post < ActiveRecord::Base
|
82
88
|
include DestroyedAt
|
83
89
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: destroyed_at
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Dupuis Jr.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -144,6 +144,7 @@ extensions: []
|
|
144
144
|
extra_rdoc_files: []
|
145
145
|
files:
|
146
146
|
- ".gitignore"
|
147
|
+
- ".ruby-version"
|
147
148
|
- ".travis.yml"
|
148
149
|
- CHANGELOG.md
|
149
150
|
- CONTRIBUTING.md
|
@@ -182,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
183
|
version: '0'
|
183
184
|
requirements: []
|
184
185
|
rubyforge_project:
|
185
|
-
rubygems_version: 2.
|
186
|
+
rubygems_version: 2.2.3
|
186
187
|
signing_key:
|
187
188
|
specification_version: 4
|
188
189
|
summary: Safe destroy for ActiveRecord.
|