identity_cache 0.5.0 → 0.5.1

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: 11bd2d6f14e2b77b00c8bd58dd0731fa2976a81a
4
- data.tar.gz: 4d547e1b739ce13b443dfb9ea44416a81936ed95
3
+ metadata.gz: c9803848d2879cfdaad2424842b64db3684e1ca4
4
+ data.tar.gz: 91cd873cffd35d19d66b01c8a10165344b30483d
5
5
  SHA512:
6
- metadata.gz: 63aa5192013b0d99b426e0b1cf70ea6962924a57da29beaac507b4d5dae458693822a55cd24bc743768826d7b725592b456c0ca68cc9655df5509100a0ab68b3
7
- data.tar.gz: 99cab0e7c1b4d8a4a5378b408582486404182e86529d4e62926d29ab3c021a2ff9af02a4af05d0a5eae4cd6996a76f4588a4e03584645025d7c7131a122407fd
6
+ metadata.gz: d65519bb48cdae9d0111280e05a89cee2e99a497f31d0140f3e77ca55226865ef8c575ec9bd427e41ba9fd105e304c0a006d2fa4348ce6b06393c0ed607a8e23
7
+ data.tar.gz: 370c4a4d3406b95b9fe40b33406182286d9586dc07db2f2517a87bb08111fafa776dead8a5430555564aefdb385a9f5ce027c511e87c32924a8e8668af00a863
@@ -1,5 +1,9 @@
1
1
  # IdentityCache changelog
2
2
 
3
+ #### 0.5.1
4
+
5
+ - Fix bug in prefetch_associations for cache_has_one associations that may be nil
6
+
3
7
  #### 0.5.0
4
8
 
5
9
  - `never_set_inverse_association` and `fetch_read_only_records` are now `true` by default (#315)
@@ -401,7 +401,7 @@ module IdentityCache
401
401
  when details = cached_has_ones[association]
402
402
  if details[:embed] == true
403
403
  prefetch_embedded_association(records, association, details)
404
- parent_records = records.map(&details[:cached_accessor_name].to_sym)
404
+ parent_records = records.map(&details[:cached_accessor_name].to_sym).compact
405
405
  else
406
406
  raise ArgumentError.new("Non-embedded has_one associations do not support prefetching yet.")
407
407
  end
@@ -1,4 +1,4 @@
1
1
  module IdentityCache
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  CACHE_VERSION = 7
4
4
  end
@@ -124,6 +124,21 @@ class PrefetchAssociationsTest < IdentityCache::TestCase
124
124
  end
125
125
  end
126
126
 
127
+ def test_prefetch_associations_through_nil_cache_has_one_association
128
+ Item.send(:cache_has_one, :associated, embed: true)
129
+ AssociatedRecord.send(:cache_has_many, :deeply_associated_records, embed: :ids)
130
+ bob_child = @bob.create_associated!(name: "bob child")
131
+ bob_child.deeply_associated_records.create!(name: "deep child")
132
+ AssociatedRecord.fetch_multi(bob_child.id)
133
+ Item.fetch_multi(@bob.id, @joe.id)
134
+
135
+ assert_memcache_operations(2) do
136
+ cached_bob, cached_joe = Item.fetch_multi(@bob.id, @joe.id, includes: {:associated => :deeply_associated_records})
137
+ assert_nil cached_joe.fetch_associated
138
+ assert_equal 'deep child', cached_bob.fetch_associated.fetch_deeply_associated_records.first.name
139
+ end
140
+ end
141
+
127
142
  def test_fetch_with_includes_option
128
143
  Item.send(:cache_belongs_to, :item)
129
144
  john = Item.create!(title: 'john')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: identity_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Camilo Lopez
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2017-02-07 00:00:00.000000000 Z
17
+ date: 2017-02-09 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: ar_transaction_changes