active_record-json_associations 0.6.5 → 0.6.6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be9f54a9dea98a2fefa8a354fd1e80420ae77902
|
4
|
+
data.tar.gz: ac5aca1680ada8e5ccbc98034920c6f734205bc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc3c75d60285319e34cdd10aaf58a9820fabde5aa96885483e2409cfdf31c01aa6eadbf9605382929e1a1a2c883bd22ae223faf26c6236d189e6d8ccb5faa2fa
|
7
|
+
data.tar.gz: e5e5e5b34a13778dc8d8e4905215905321fd288769ddde3d0d751c226841db93d24a601fb35c0b206499ea1e2e539d843f0e4927b55267c6624309dd1e4e21d7
|
@@ -66,7 +66,8 @@ module ActiveRecord
|
|
66
66
|
|
67
67
|
define_method one_ids_equals do |ids|
|
68
68
|
klass = class_name.constantize
|
69
|
-
|
69
|
+
normalized_ids = Array(ids).select(&:present?).map(&:to_i)
|
70
|
+
send many_equals, klass.find(normalized_ids)
|
70
71
|
end
|
71
72
|
|
72
73
|
define_method many do
|
@@ -123,6 +123,20 @@ describe ActiveRecord::JsonAssociations do
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
+
describe "#parent_ids=" do
|
127
|
+
before { parents } # ensure parents exist
|
128
|
+
|
129
|
+
it "normalizes to integers" do
|
130
|
+
subject.parent_ids = ["1",2,"3"]
|
131
|
+
expect(subject.parent_ids).to eq [1,2,3]
|
132
|
+
end
|
133
|
+
|
134
|
+
it "ignores empty strings" do
|
135
|
+
subject.parent_ids = ["","1","2","3"]
|
136
|
+
expect(subject.parent_ids).to eq [1,2,3]
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
126
140
|
describe "#parents" do
|
127
141
|
it "returns an empty array when there are no parents" do
|
128
142
|
expect(subject.parents).to eq []
|
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.6.
|
4
|
+
version: 0.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micah Geisel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03
|
11
|
+
date: 2017-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|