activerecord-collection_cache_key 0.1.0 → 0.1.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: 185f1aa953f1bb441199195b36f2c22e1471122a
4
- data.tar.gz: 36b7816b234d9dddc9e2f605be97ace092ac1262
3
+ metadata.gz: ccd76e94d73ec763de6290eaae3ec459221513c1
4
+ data.tar.gz: 525b88d710b5a74411060ed912651a71ff79fb0a
5
5
  SHA512:
6
- metadata.gz: 23ca1e42e9cd13102c39baddab18983276c8e92a1049de7eb808c0978ebe4b7e1d007e602feb73f206c2dd1900671f916ceab344fa7900c58ddde61b5681e14f
7
- data.tar.gz: df4d5880037892e005c253150bf25b6cdbe5a1d69cb298636870bde27e2b21dd690d86300eb2405f54cc426c70a74d016a761fdfef08d9799923234c4d024dc7
6
+ metadata.gz: 788fcb1ebfcd065bd3786b8a7ef7d52b2b74e1e04660ebd5756689ea37f10bc607f5f4251ea2317750477674c1d66a4fbcaf7edea9341f658b9dc1109a9a4553
7
+ data.tar.gz: 1ef020a747534e3a6949f54d098a0ebedaa8855e9f8d37d086f31db6a25679e6321c40086306b8902635e3016c1ace119ab9f6844ab58704aee16ccb6ebbc81e
data/CHANGELOG.md CHANGED
@@ -9,3 +9,10 @@ Initial Release
9
9
  taken into account in the cache key; this will err toward expiring too much
10
10
  rather than too little, and will *always* do a count query regardless of
11
11
  whether the relation is loaded or not.
12
+
13
+ ## v0.1.1 - 2016-04-01
14
+
15
+ Bugfix
16
+
17
+ * Corrects a bug where models with a `#size` or `#timestamp` method could
18
+ fail to generate a proper cache key.
@@ -25,8 +25,9 @@ module CollectionCacheKey
25
25
  column = "#{connection.quote_table_name(collection.table_name)}.#{connection.quote_column_name(timestamp_column)}"
26
26
  query = collection.dup
27
27
  result = query.select("COUNT(*) AS size, MAX(#{column}) AS timestamp").first
28
+ attrs = result.attributes
28
29
 
29
- [query_key(collection), result.size, parsed_timestamp(result.timestamp)]
30
+ [query_key(collection), attrs['size'], parsed_timestamp(attrs['timestamp'])]
30
31
  end
31
32
 
32
33
  def query_key(collection)
@@ -2,7 +2,7 @@ module CollectionCacheKey
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- PATCH = 0
5
+ PATCH = 1
6
6
  PRE = nil
7
7
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
8
8
  end
@@ -35,6 +35,18 @@ class CollectionCacheKeyTest < CollectionCacheKey::TestCase
35
35
  .must_equal("#{cache_namespace}/query-#{digest}-10-#{original_time_str}")
36
36
  end
37
37
 
38
+ it 'avoids method name collisions with the key generation internals' do
39
+ subject.class_eval do
40
+ def size
41
+ 999_999
42
+ end
43
+ end
44
+
45
+ digest = Digest::MD5.hexdigest(default_sql)
46
+ subject.collection_cache_key
47
+ .must_equal("#{cache_namespace}/query-#{digest}-10-#{original_time_str}")
48
+ end
49
+
38
50
  it 'updates the cache_key when a record changes' do
39
51
  subject.first.update_attributes(updated_at: update_time)
40
52
  digest = Digest::MD5.hexdigest(default_sql)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-collection_cache_key
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Drinkard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-21 00:00:00.000000000 Z
11
+ date: 2016-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord