second_level_cache 2.1.13 → 2.1.14

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: 87a71a85a2abc58df0d9cc05f15b2a1c36c92339
4
- data.tar.gz: 152a0f37f8793d8bfbb699cdc2887e51860d1143
3
+ metadata.gz: 7686a42b44f437f2e6fc609d96522d1379b7a200
4
+ data.tar.gz: ba2e25b305dbfdcd28422f7336a4d626799eb248
5
5
  SHA512:
6
- metadata.gz: 06a26ebf58a7f3f516c639a5f95abbb95a06dda1b24a8a686718b854f5383e53df75440ec23c2ea16cd5a94a6e7f606d05bfea24f9c547e5be1329efea77dcf9
7
- data.tar.gz: aa21915860466947a13ab3c792b83a98e40accc785459ad303a9fc03060d4ba70c673554964512b4baa80de1cb6ae2a3ff3a8f56c33bdff92ee0b59398afdda9
6
+ metadata.gz: 80c5b721865aa021c8e849b2fd9e55fe76f70b1d4bb9d1f15c8f0219e46ce2f55cc87314c1db8c03fcfc9b1606078d9d23362dbba2a54fb7891877536ca4e081
7
+ data.tar.gz: a324360eb82ba9b00045aca3e85e6e7c6cef69376b91de60cef776c9c5b432467d1f7728c0dcb59965bf37a6048432a2e463b71e830d2867905586d5c7514fdd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ 2.1.14
2
+ * support has_one with scope
3
+
1
4
  2.1.10
2
5
  * read multi from cache for find(ids)
3
6
 
@@ -12,10 +12,13 @@ module SecondLevelCache
12
12
 
13
13
  def find_target_with_second_level_cache
14
14
  return find_target_without_second_level_cache unless klass.second_level_cache_enabled?
15
- return find_target_without_second_level_cache if reflection.options[:through] || reflection.scope
16
- # TODO: implement cache with has_one through, scope
15
+
16
+ return find_target_without_second_level_cache if reflection.options[:through]
17
+ # TODO: implement cache with has_one through
17
18
  if reflection.options[:as]
18
19
  cache_record = klass.fetch_by_uniq_keys({reflection.foreign_key => owner[reflection.active_record_primary_key], reflection.type => owner.class.base_class.name})
20
+ elsif reflection.scope
21
+ cache_record = klass.fetch_by_uniq_keys(create_scope)
19
22
  else
20
23
  cache_record = klass.fetch_by_uniq_key(owner[reflection.active_record_primary_key], reflection.foreign_key)
21
24
  end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
- module SecondLevelCache
3
- VERSION = "2.1.13"
2
+ module SecondLevelCache
3
+ VERSION = "2.1.14"
4
4
  end
@@ -31,7 +31,11 @@ class HasOneAssociationTest < ActiveSupport::TestCase
31
31
  user.create_namespace(name: 'hooopo')
32
32
  group_namespace2 = Namespace.create(user_id: user.id, name: 'rails', kind: 'group')
33
33
  assert_not_equal user.namespace, nil
34
- clear_user = User.find(user.id)
34
+ assert_equal user.reload.namespace.name, 'hooopo'
35
+ clear_user = user.reload
36
+ assert_no_queries do
37
+ clear_user.namespace
38
+ end
35
39
  assert_equal clear_user.namespace.name, 'hooopo'
36
40
  end
37
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: second_level_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.13
4
+ version: 2.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hooopo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-07 00:00:00.000000000 Z
11
+ date: 2016-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport