kasket 2.1.2 → 2.2.0
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.
- data/lib/kasket.rb +6 -4
- data/lib/kasket/version.rb +2 -2
- data/test/reload_test.rb +0 -79
- metadata +4 -4
data/lib/kasket.rb
CHANGED
@@ -34,11 +34,13 @@ module Kasket
|
|
34
34
|
Arel::SelectManager.send(:include, Kasket::SelectManagerMixin)
|
35
35
|
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
ActiveRecord::
|
37
|
+
if options[:assoliations_reload_hack]
|
38
|
+
ActiveRecord::Associations::BelongsToAssociation.send(:include, Kasket::ReloadAssociationMixin)
|
39
|
+
if ActiveRecord::VERSION::MAJOR == 2 || AR30
|
40
|
+
ActiveRecord::Associations::BelongsToPolymorphicAssociation.send(:include, Kasket::ReloadAssociationMixin)
|
41
|
+
end
|
42
|
+
ActiveRecord::Associations::HasOneThroughAssociation.send(:include, Kasket::ReloadAssociationMixin)
|
40
43
|
end
|
41
|
-
ActiveRecord::Associations::HasOneThroughAssociation.send(:include, Kasket::ReloadAssociationMixin)
|
42
44
|
end
|
43
45
|
|
44
46
|
def self.cache_store=(options)
|
data/lib/kasket/version.rb
CHANGED
data/test/reload_test.rb
CHANGED
@@ -1,49 +1,6 @@
|
|
1
1
|
require File.expand_path("helper", File.dirname(__FILE__))
|
2
2
|
|
3
3
|
class ReloadTest < ActiveSupport::TestCase
|
4
|
-
context "Loading a polymorphic belongs_to" do
|
5
|
-
should "not clear cache when loading nil" do
|
6
|
-
@post = Post.first
|
7
|
-
@post.poly = nil
|
8
|
-
@post.save!
|
9
|
-
Kasket.expects(:clear_local).never
|
10
|
-
assert_nil @post.poly
|
11
|
-
end
|
12
|
-
|
13
|
-
context "that is uncached" do
|
14
|
-
setup do
|
15
|
-
@post = Post.first
|
16
|
-
@post.poly = Blog.first
|
17
|
-
@post.save!
|
18
|
-
assert @post.poly
|
19
|
-
end
|
20
|
-
|
21
|
-
should "not clear local when it is unloaded" do
|
22
|
-
Kasket.expects(:clear_local).never
|
23
|
-
assert Post.first.poly
|
24
|
-
end
|
25
|
-
|
26
|
-
should "not clear local when it is loaded" do
|
27
|
-
Kasket.expects(:clear_local).never
|
28
|
-
assert @post.poly.reload
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context "that is cached" do
|
33
|
-
setup do
|
34
|
-
@post = Post.first
|
35
|
-
@post.poly = Comment.first
|
36
|
-
@post.save!
|
37
|
-
assert @post.poly
|
38
|
-
end
|
39
|
-
|
40
|
-
should "clear local when it is loaded" do
|
41
|
-
Kasket.expects(:clear_local)
|
42
|
-
@post.poly.reload
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
4
|
context "Reloading a model" do
|
48
5
|
setup do
|
49
6
|
@post = Post.first
|
@@ -57,40 +14,4 @@ class ReloadTest < ActiveSupport::TestCase
|
|
57
14
|
end
|
58
15
|
end
|
59
16
|
|
60
|
-
context "Reloading a belongs_to association" do
|
61
|
-
setup do
|
62
|
-
@post = Comment.first.post
|
63
|
-
assert @post
|
64
|
-
assert @post.title
|
65
|
-
end
|
66
|
-
|
67
|
-
should "clear local cache" do
|
68
|
-
Kasket.expects(:clear_local)
|
69
|
-
@post.reload
|
70
|
-
end
|
71
|
-
|
72
|
-
should "reload via true" do
|
73
|
-
@comment = Comment.first
|
74
|
-
assert_equal "few_comments", @comment.post.title
|
75
|
-
|
76
|
-
Post.update_all("title = 'yyy'", :id => @comment.post_id)
|
77
|
-
|
78
|
-
assert_equal "few_comments", @comment.post.title
|
79
|
-
@comment.post(true) # it does not blow up
|
80
|
-
#assert_equal "yyy", @comment.post(true).title # TODO broken in all rails versions...
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
context "Reloading a has_one_through association" do
|
85
|
-
setup do
|
86
|
-
@author = Comment.first.author
|
87
|
-
assert @author
|
88
|
-
assert @author.name
|
89
|
-
end
|
90
|
-
|
91
|
-
should "clear local cache" do
|
92
|
-
Kasket.expects(:clear_local)
|
93
|
-
@author.reload
|
94
|
-
end
|
95
|
-
end
|
96
17
|
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: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-12-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -183,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
183
183
|
version: '0'
|
184
184
|
segments:
|
185
185
|
- 0
|
186
|
-
hash:
|
186
|
+
hash: 3681071488185082983
|
187
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
188
|
none: false
|
189
189
|
requirements:
|
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
192
|
version: '0'
|
193
193
|
segments:
|
194
194
|
- 0
|
195
|
-
hash:
|
195
|
+
hash: 3681071488185082983
|
196
196
|
requirements: []
|
197
197
|
rubyforge_project:
|
198
198
|
rubygems_version: 1.8.24
|