kasket 3.1.2 → 3.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kasket/read_mixin.rb +2 -2
- data/lib/kasket/version.rb +1 -1
- data/lib/kasket/write_mixin.rb +2 -15
- data/test/fixtures/posts.yml +1 -0
- data/test/helper.rb +5 -1
- data/test/read_mixin_test.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c6bfa50affd0410b4118a393a9f058c54149bac
|
4
|
+
data.tar.gz: fec8fa3b11f35c364b9e5c26448830d0331a5082
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65e2baa04a767f94209a508a4b853bd17dfc318803a3afbcd6fd650ede78ec65cc9510567d867d0a2e8ce416b9eb125d7578fff02bf6f5fbab701f2f1dc50202
|
7
|
+
data.tar.gz: 5523ee1be9feeaddf7b62276c01d1ba620d9e482cd814b39ac2e3b0348aaec1c37c3b52e92a122918450159bfece81daae341b921cf9637cd3f02ef0e3faeac6
|
data/lib/kasket/read_mixin.rb
CHANGED
@@ -63,7 +63,7 @@ module Kasket
|
|
63
63
|
def store_in_kasket(key, records)
|
64
64
|
if records.size == 1
|
65
65
|
if records.first.kasket_cacheable?
|
66
|
-
Kasket.cache.write(key, records.first.
|
66
|
+
Kasket.cache.write(key, records.first.attributes_before_type_cast.dup)
|
67
67
|
end
|
68
68
|
elsif records.empty?
|
69
69
|
ActiveRecord::Base.logger.info("[KASKET] would have stored an empty resultset") if ActiveRecord::Base.logger
|
@@ -71,7 +71,7 @@ module Kasket
|
|
71
71
|
if records.all?(&:kasket_cacheable?)
|
72
72
|
instance_keys = records.map do |record|
|
73
73
|
instance_key = kasket_key_for_id(record.id)
|
74
|
-
Kasket.cache.write(instance_key, record.
|
74
|
+
Kasket.cache.write(instance_key, record.attributes_before_type_cast.dup)
|
75
75
|
instance_key
|
76
76
|
end
|
77
77
|
|
data/lib/kasket/version.rb
CHANGED
data/lib/kasket/write_mixin.rb
CHANGED
@@ -37,7 +37,6 @@ module Kasket
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def kasket_keys
|
40
|
-
return @kasket_keys if @kasket_keys
|
41
40
|
attribute_sets = [attributes.symbolize_keys]
|
42
41
|
|
43
42
|
if changed?
|
@@ -58,16 +57,10 @@ module Kasket
|
|
58
57
|
keys
|
59
58
|
end
|
60
59
|
|
61
|
-
def remember_kasket_keys
|
62
|
-
@kasket_keys = kasket_keys
|
63
|
-
end
|
64
|
-
|
65
60
|
def clear_kasket_indices
|
66
61
|
kasket_keys.each do |key|
|
67
62
|
Kasket.cache.delete(key)
|
68
63
|
end
|
69
|
-
@kasket_keys = nil
|
70
|
-
true
|
71
64
|
end
|
72
65
|
|
73
66
|
def reload_with_kasket_clearing(*args)
|
@@ -84,14 +77,8 @@ module Kasket
|
|
84
77
|
model_class.send(:alias_method, :kasket_cacheable?, :default_kasket_cacheable?)
|
85
78
|
end
|
86
79
|
|
87
|
-
|
88
|
-
|
89
|
-
model_class.after_destroy :remember_kasket_keys
|
90
|
-
model_class.after_commit :clear_kasket_indices
|
91
|
-
else
|
92
|
-
model_class.after_save :clear_kasket_indices
|
93
|
-
model_class.after_destroy :clear_kasket_indices
|
94
|
-
end
|
80
|
+
model_class.after_save :clear_kasket_indices
|
81
|
+
model_class.after_destroy :clear_kasket_indices
|
95
82
|
|
96
83
|
model_class.alias_method_chain :reload, :kasket_clearing
|
97
84
|
|
data/test/fixtures/posts.yml
CHANGED
data/test/helper.rb
CHANGED
@@ -14,8 +14,12 @@ end
|
|
14
14
|
require 'test/unit'
|
15
15
|
require 'mocha'
|
16
16
|
require 'active_record'
|
17
|
+
|
18
|
+
raise "Must configure #time_zone_aware_attributes prior to models" if defined?(Post)
|
19
|
+
ENV['TZ'] = 'utc'
|
20
|
+
ActiveRecord::Base.time_zone_aware_attributes = true
|
21
|
+
|
17
22
|
require 'active_record/fixtures'
|
18
|
-
require 'test_after_commit' if ActiveRecord::Base.respond_to?(:after_commit)
|
19
23
|
|
20
24
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
21
25
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
data/test/read_mixin_test.rb
CHANGED
@@ -76,4 +76,14 @@ class ReadMixinTest < ActiveSupport::TestCase
|
|
76
76
|
assert_equal({'sex' => 'male'}, author.metadata)
|
77
77
|
end
|
78
78
|
|
79
|
+
should "not store time with zone" do
|
80
|
+
Time.use_zone(ActiveSupport::TimeZone.all.first) do
|
81
|
+
post = posts(:no_comments)
|
82
|
+
post = Post.find(post.id)
|
83
|
+
object = Kasket.cache.read("#{Post.kasket_key_prefix}id=#{post.id}")
|
84
|
+
|
85
|
+
assert_equal "2013-10-14 15:30:00", object["created_at"].to_s, object["created_at"].class
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
79
89
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kasket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mick Staugaard
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|