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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cbbbb6b9f11d63c2ad2d8f8124145abb685dfa3a
4
- data.tar.gz: 5e8df40dcbbcc08410b3922477497d7b70eab7d6
3
+ metadata.gz: 0c6bfa50affd0410b4118a393a9f058c54149bac
4
+ data.tar.gz: fec8fa3b11f35c364b9e5c26448830d0331a5082
5
5
  SHA512:
6
- metadata.gz: 8222b347d102168e89f29b87054f101e73b41878a284172d2caf1b54ed7392df4fd7e6aca168efbdafb8afbcfc224a9532ce6a10c01cb027f77cf2d74242fe7b
7
- data.tar.gz: 0ead621748e7e32605d08deec8a5353659ffed31236ba8c983fc35ca32b92f6a11ecfd9027366e33bd83e996bd5b9151ecec097ac01a224fb77595c4acb36d6e
6
+ metadata.gz: 65e2baa04a767f94209a508a4b853bd17dfc318803a3afbcd6fd650ede78ec65cc9510567d867d0a2e8ce416b9eb125d7578fff02bf6f5fbab701f2f1dc50202
7
+ data.tar.gz: 5523ee1be9feeaddf7b62276c01d1ba620d9e482cd814b39ac2e3b0348aaec1c37c3b52e92a122918450159bfece81daae341b921cf9637cd3f02ef0e3faeac6
@@ -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.attributes.dup)
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.attributes.dup)
74
+ Kasket.cache.write(instance_key, record.attributes_before_type_cast.dup)
75
75
  instance_key
76
76
  end
77
77
 
@@ -3,7 +3,7 @@ module Kasket
3
3
  class Version
4
4
  MAJOR = 3
5
5
  MINOR = 1
6
- PATCH = 2
6
+ PATCH = 3
7
7
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
8
8
  PROTOCOL = 4
9
9
  end
@@ -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
- if model_class.respond_to?(:after_commit)
88
- model_class.after_save :remember_kasket_keys
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
 
@@ -3,6 +3,7 @@ no_comments:
3
3
  blog: a_blog
4
4
  title: no_comments
5
5
  author: mick
6
+ created_at: 2013-10-14 15:30:00
6
7
 
7
8
  has_two_comments:
8
9
  id: 2
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__))
@@ -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.2
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-09-23 00:00:00.000000000 Z
12
+ date: 2013-10-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord