destroyed_at 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -0
- data/destroyed_at.gemspec +1 -1
- data/lib/destroyed_at.rb +4 -0
- data/lib/destroyed_at/belongs_to_association.rb +1 -1
- data/lib/destroyed_at/has_one_association.rb +2 -2
- data/lib/destroyed_at/version.rb +1 -1
- data/test/destroyed_at_test.rb +13 -1
- data/test/test_helper.rb +10 -0
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7d179e6fcbc606b511c8f487d48cc6bf51b48aa
|
4
|
+
data.tar.gz: 3a5163d54f812bee7ccffb46efb59724a806094f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f837e70ea9b18712645e0d710c230dde370d300bc2184a88f0a70223c662066c61c3749f2e6e50ee4f5825b8567c6fff2948528d041ac4ac621cf1fad31b1038
|
7
|
+
data.tar.gz: b5355d8bf3b48f2f6dbe4ebbbc899b8931c4b8d68d62572d82afaef45f0f81d793b1815f3510669fdf9748f5733bb2701c166c410097f0e0a3849fcaa1239d8a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 1.0.1
|
2
|
+
* Fixes an issue with where the incorrect arguments were being passed
|
3
|
+
from inside the `BelongsToAssociation` and `HasOneAssociation`, as
|
4
|
+
reported by [anarchocurious](https://github.com/anarchocurious)
|
5
|
+
|
1
6
|
## 1.0.0
|
2
7
|
|
3
8
|
* Requires equal to or greater than Ruby `2.0` -
|
data/Gemfile
CHANGED
data/destroyed_at.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["michael.dupuis@dockyard.com"]
|
11
11
|
spec.description = %q{Safe destroy for ActiveRecord.}
|
12
12
|
spec.summary = %q{Safe destroy for ActiveRecord.}
|
13
|
-
spec.homepage = "https://github.com/dockyard/destroyed_at"
|
13
|
+
spec.homepage = "https://github.com/dockyard/ruby-destroyed_at"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
data/lib/destroyed_at.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module DestroyedAt
|
2
2
|
module HasOneAssociation
|
3
3
|
def delete(method = options[:dependent])
|
4
|
-
if load_target && method == :destroy
|
5
|
-
DestroyedAt.destroy_target_of_association(
|
4
|
+
if DestroyedAt.has_destroy_at?(target) && load_target && method == :destroy
|
5
|
+
DestroyedAt.destroy_target_of_association(owner, target)
|
6
6
|
else
|
7
7
|
super
|
8
8
|
end
|
data/lib/destroyed_at/version.rb
CHANGED
data/test/destroyed_at_test.rb
CHANGED
@@ -79,7 +79,7 @@ describe 'destroying an activerecord instance' do
|
|
79
79
|
author.destroy!
|
80
80
|
|
81
81
|
Author.count.must_equal 0
|
82
|
-
Avatar.count.must_equal
|
82
|
+
Avatar.count.must_equal 0
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
@@ -182,3 +182,15 @@ describe 'creating a destroyed record' do
|
|
182
182
|
post.persisted?.must_equal false
|
183
183
|
end
|
184
184
|
end
|
185
|
+
|
186
|
+
describe 'non destroyed-at models' do
|
187
|
+
it 'can destroy has_on dependants' do
|
188
|
+
person = Person.create!
|
189
|
+
pet = person.create_pet!
|
190
|
+
|
191
|
+
person.destroy
|
192
|
+
|
193
|
+
assert_equal(0, Person.count, 'Person must be zero')
|
194
|
+
assert_equal(0, Pet.count, 'Pet must be zero')
|
195
|
+
end
|
196
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -35,12 +35,22 @@ ActiveRecord::Base.connection.execute(%{CREATE TABLE comments (id INTEGER PRIMAR
|
|
35
35
|
ActiveRecord::Base.connection.execute(%{CREATE TABLE commenters (id INTEGER PRIMARY KEY, destroyed_at DATETIME);})
|
36
36
|
ActiveRecord::Base.connection.execute(%{CREATE TABLE images (id INTEGER PRIMARY KEY, post_id INTEGER);})
|
37
37
|
ActiveRecord::Base.connection.execute(%{CREATE TABLE posts (id INTEGER PRIMARY KEY, author_id INTEGER, destroyed_at DATETIME);})
|
38
|
+
ActiveRecord::Base.connection.execute(%{CREATE TABLE people (id INTEGER PRIMARY KEY);})
|
39
|
+
ActiveRecord::Base.connection.execute(%{CREATE TABLE pets (id INTEGER PRIMARY KEY, person_id INTEGER);})
|
38
40
|
|
39
41
|
class Author < ActiveRecord::Base
|
40
42
|
has_many :posts
|
41
43
|
has_one :avatar, dependent: :destroy
|
42
44
|
end
|
43
45
|
|
46
|
+
class Person < ActiveRecord::Base
|
47
|
+
has_one :pet, dependent: :destroy
|
48
|
+
end
|
49
|
+
|
50
|
+
class Pet < ActiveRecord::Base
|
51
|
+
belongs_to :person
|
52
|
+
end
|
53
|
+
|
44
54
|
class Avatar < ActiveRecord::Base
|
45
55
|
include DestroyedAt
|
46
56
|
belongs_to :author
|
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.1
|
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:
|
11
|
+
date: 2015-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -162,7 +162,7 @@ files:
|
|
162
162
|
- test/mapper_test.rb
|
163
163
|
- test/scope_test.rb
|
164
164
|
- test/test_helper.rb
|
165
|
-
homepage: https://github.com/dockyard/destroyed_at
|
165
|
+
homepage: https://github.com/dockyard/ruby-destroyed_at
|
166
166
|
licenses:
|
167
167
|
- MIT
|
168
168
|
metadata: {}
|
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
182
|
version: '0'
|
183
183
|
requirements: []
|
184
184
|
rubyforge_project:
|
185
|
-
rubygems_version: 2.
|
185
|
+
rubygems_version: 2.4.5
|
186
186
|
signing_key:
|
187
187
|
specification_version: 4
|
188
188
|
summary: Safe destroy for ActiveRecord.
|
@@ -191,4 +191,3 @@ test_files:
|
|
191
191
|
- test/mapper_test.rb
|
192
192
|
- test/scope_test.rb
|
193
193
|
- test/test_helper.rb
|
194
|
-
has_rdoc:
|