active_record-json_associations 0.6.5 → 0.6.6

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
  SHA1:
3
- metadata.gz: 4348ec4c6f40c8428b39e5939de016e8c8f73e8c
4
- data.tar.gz: 82e9d510c5c6aac1c8829af42b97f26d8a9c6cc6
3
+ metadata.gz: be9f54a9dea98a2fefa8a354fd1e80420ae77902
4
+ data.tar.gz: ac5aca1680ada8e5ccbc98034920c6f734205bc8
5
5
  SHA512:
6
- metadata.gz: 0b7204f1470b38fae8ea2ee590da515d577942739cd837628401eeed5024f9022ab71df09ba3c57af12ca3b36b9e02357fe3507c83e3d001185a46807d6255a4
7
- data.tar.gz: 2729ef38c50d066eab6d0b7841809df80d6ed727ae5286bb9d206fc80c2f0a2c0ce35505b8b2e3e4647d3b181401277757f4ce9dbf09cbdbc50f89f269c3473c
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
- send many_equals, klass.find(ids)
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
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module JsonAssociations
3
- VERSION = "0.6.5"
3
+ VERSION = "0.6.6"
4
4
  end
5
5
  end
@@ -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.5
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-17 00:00:00.000000000 Z
11
+ date: 2017-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord