active_record-json_associations 0.9.0 → 0.9.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e03d284df9e4faf9319475962d17aee50025fc58407f1cb641819c070958eca6
|
4
|
+
data.tar.gz: 026dff5c42712728a8c85a59e413265f3c1c09922ec1fc366fee5db3404fb42a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 449f81549f3ed177a88ce17070a92b2f6b07f252193ab1cf64d706d51c85d9065f636af21242bd3a689f1b2402384d2d0487c58cc74de1f07b1c3f441da3b34d
|
7
|
+
data.tar.gz: 5dea4c68f936961403ca768f7775795fe810df3e811cadb147901faa0e2e5313512853aed0d5bdaaabefafaeb60f9cdc3375d5d5d986ca2cde42be6759b94125
|
@@ -24,12 +24,9 @@ module ActiveRecord
|
|
24
24
|
|
25
25
|
if touch
|
26
26
|
after_commit do
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
old_ids, new_ids = previous_changes[one_ids.to_s]
|
31
|
-
end
|
32
|
-
ids = Array(old_ids) | Array(new_ids)
|
27
|
+
method = respond_to?(:saved_changes) ? :saved_changes : :previous_changes
|
28
|
+
old_ids, new_ids = send(method)[one_ids.to_s]
|
29
|
+
ids = Array(send(one_ids)) | Array(old_ids) | Array(new_ids)
|
33
30
|
scope = class_name.constantize.where(self.class.primary_key => ids)
|
34
31
|
|
35
32
|
if scope.respond_to?(:touch) # AR 6.0+
|
@@ -153,7 +153,7 @@ describe ActiveRecord::JsonAssociations do
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
-
it "touches associated
|
156
|
+
it "touches records associated upon creation" do
|
157
157
|
children = [Child.create!(updated_at: old_time), Child.create!(updated_at: old_time)]
|
158
158
|
fuzzies = [Pet.create!(updated_at: old_time), Pet.create!(updated_at: old_time)]
|
159
159
|
parent = Parent.create!(children: children, fuzzies: fuzzies)
|
@@ -161,6 +161,14 @@ describe ActiveRecord::JsonAssociations do
|
|
161
161
|
expect(fuzzies.each(&:reload).map(&:updated_at)).to eq [old_time, old_time] # touch: nil
|
162
162
|
end
|
163
163
|
|
164
|
+
it "touches exising association records" do
|
165
|
+
children = [Child.create!, Child.create!]
|
166
|
+
parent = Parent.create!(children: children)
|
167
|
+
children.each { |child| child.update!(updated_at: old_time) }
|
168
|
+
parent.save!
|
169
|
+
expect(children.each(&:reload).map(&:updated_at)).to eq [new_time, new_time]
|
170
|
+
end
|
171
|
+
|
164
172
|
it "touches removed associated records" do
|
165
173
|
peter, paul, mary = Child.create!, Child.create!, Child.create!
|
166
174
|
parent = Parent.create!(children: [peter, paul, mary])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record-json_associations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micah Geisel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|