simple_cacheable 1.4.0 → 1.4.1

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: 84641f34cae9d9da455523484d0a802851c938ed
4
- data.tar.gz: 951f43891133aa8e58d6235d686cc2427b407dcb
3
+ metadata.gz: 82a842613fa2c2177a47105e827c286a0c959e4e
4
+ data.tar.gz: 21bcf0508eb353b7f4899392f47951138a4a3f3d
5
5
  SHA512:
6
- metadata.gz: 99d9989b5970e995a3212583ae721802d04e1acb6e5ca4384213083926e03235f97f663027c599cdc4bbaba28ba6d0fc832813e18df2e7439e6994ead01f2985
7
- data.tar.gz: 8dd71f349161ed02e8f63482e9a0e9dd88f98c12cdbbd7e2555fe3a217a7099c29ff5ec414dd79f98e2835a88878503a75f5cc32640129d25d691a79e5d708c8
6
+ metadata.gz: 8aef917182c022c49718748fef29f2b1b9152526d2de85021ccff9082386d3620ef867fe677a5c087c99ccbdb63cf3b4067a032db497ab6db728d3a5fc357edd
7
+ data.tar.gz: 046e1c0509df6ee8ad09a35865515ada8927018881b333fe2698146aa561c0f5ff2e237a750eee1a0a08ef5550adb298907a64f34e44239d4750dafe178eab0b
data/ChangeLog CHANGED
@@ -1,3 +1,6 @@
1
+ 1.4.1
2
+ * Fixed all silent failures for assocations that didn't exist
3
+
1
4
  1.4.0
2
5
  * Fixed after_commit silent failure for assocations that didn't exist
3
6
  * Fixed association for has_many through when there are several belongs_to relationships
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_cacheable (1.3.3)
4
+ simple_cacheable (1.4.0)
5
5
  rails (>= 3.0.0)
6
6
 
7
7
  GEM
@@ -25,9 +25,9 @@ GEM
25
25
  activesupport (= 4.0.0)
26
26
  arel (~> 4.0.0)
27
27
  activerecord-deprecated_finders (1.0.3)
28
- activerecord-jdbc-adapter (1.2.2.1)
29
- activerecord-jdbcsqlite3-adapter (1.2.2.1)
30
- activerecord-jdbc-adapter (~> 1.2.2.1)
28
+ activerecord-jdbc-adapter (1.2.9.1)
29
+ activerecord-jdbcsqlite3-adapter (1.2.9)
30
+ activerecord-jdbc-adapter (~> 1.2.9)
31
31
  jdbc-sqlite3 (~> 3.7.2)
32
32
  activesupport (4.0.0)
33
33
  i18n (~> 0.6, >= 0.6.4)
@@ -43,12 +43,12 @@ GEM
43
43
  erubis (2.7.0)
44
44
  hike (1.2.3)
45
45
  i18n (0.6.4)
46
- jdbc-sqlite3 (3.7.2)
47
- jruby-memcached (0.5.1)
46
+ jdbc-sqlite3 (3.7.2.1)
47
+ jruby-memcached (0.5.5)
48
48
  mail (2.5.4)
49
49
  mime-types (~> 1.16)
50
50
  treetop (~> 1.4.8)
51
- memcached (1.4.6)
51
+ memcached (1.6.1)
52
52
  metaclass (0.0.1)
53
53
  mime-types (1.23)
54
54
  minitest (4.7.5)
@@ -92,7 +92,9 @@ GEM
92
92
  sprockets (~> 2.8)
93
93
  sqlite3 (1.3.7)
94
94
  thor (0.18.1)
95
- thread_safe (0.1.0)
95
+ thread_safe (0.1.2)
96
+ atomic
97
+ thread_safe (0.1.2-java)
96
98
  atomic
97
99
  tilt (1.4.1)
98
100
  treetop (1.4.14)
@@ -109,7 +111,7 @@ DEPENDENCIES
109
111
  activerecord-jdbcsqlite3-adapter
110
112
  jruby-memcached
111
113
  memcached
112
- mocha
113
- rspec
114
+ mocha (= 0.10.5)
115
+ rspec (= 2.8)
114
116
  simple_cacheable!
115
117
  sqlite3
data/cacheable.gemspec CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  s.description = %q{a simple cache implementation based on activerecord}
14
14
 
15
15
  s.add_dependency("rails", ">= 3.0.0")
16
- s.add_development_dependency("rspec")
17
- s.add_development_dependency("mocha")
16
+ s.add_development_dependency("rspec", "2.8")
17
+ s.add_development_dependency("mocha", "0.10.5")
18
18
 
19
19
  s.files = `git ls-files`.split("\n")
20
20
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -34,10 +34,13 @@ module Cacheable
34
34
  after_commit "expire_#{association_name}_cache".to_sym
35
35
 
36
36
  define_method("expire_#{association_name}_cache") do
37
+
37
38
  if respond_to? "expire_#{reverse_association.name}_cache".to_sym
38
- send("cached_#{reverse_association.name}").expire_association_cache(association_name)
39
- else
40
- if send(reverse_association.name) && send(reverse_association.name).respond_to?(reverse_through_association.name)
39
+ unless send("cached_#{reverse_association.name}").nil?
40
+ send("cached_#{reverse_association.name}").expire_association_cache(association_name)
41
+ end
42
+ elsif !send(reverse_association.name).nil?
43
+ if send(reverse_association.name).respond_to?(reverse_through_association.name) && !send(reverse_association.name).send(reverse_through_association.name).nil?
41
44
  send(reverse_association.name).send(reverse_through_association.name).expire_association_cache(association_name)
42
45
  end
43
46
  end
@@ -55,10 +58,13 @@ module Cacheable
55
58
 
56
59
  define_method "expire_#{association_name}_cache" do
57
60
  if respond_to? "cached_#{reverse_association.name}".to_sym
58
- # cached_viewable.expire_association_cache
59
- send("cached_#{reverse_association.name}").expire_association_cache(association_name)
60
- else
61
+ unless send("cached_#{reverse_association.name}").nil?
62
+ # cached_viewable.expire_association_cache
63
+ send("cached_#{reverse_association.name}").expire_association_cache(association_name)
64
+ end
65
+ elsif !send("#{reverse_association.name}").nil?
61
66
  send("#{reverse_association.name}").each do |assoc|
67
+ next if assoc.nil?
62
68
  assoc.expire_association_cache(association_name)
63
69
  end
64
70
  end
@@ -74,8 +80,10 @@ module Cacheable
74
80
 
75
81
  define_method "expire_#{association_name}_cache" do
76
82
  if respond_to? "cached_#{reverse_association.name}".to_sym
77
- send("cached_#{reverse_association.name}").expire_association_cache(association_name)
78
- else
83
+ unless send("cached_#{reverse_association.name}").nil?
84
+ send("cached_#{reverse_association.name}").expire_association_cache(association_name)
85
+ end
86
+ elsif !send("#{reverse_association.name}").nil?
79
87
  send("#{reverse_association.name}").expire_association_cache(association_name)
80
88
  end
81
89
  end
@@ -1,3 +1,3 @@
1
1
  module Cacheable
2
- VERSION = "1.4.0"
2
+ VERSION = "1.4.1"
3
3
  end
data/lib/cacheable.rb CHANGED
@@ -25,4 +25,4 @@ module Cacheable
25
25
  end
26
26
  end
27
27
 
28
- end
28
+ end
@@ -190,6 +190,28 @@ describe Cacheable do
190
190
  user.save
191
191
  end
192
192
 
193
+ context "with a user" do
194
+ it "should not hit expire_association_cache on save" do
195
+ account = Account.create
196
+ user = User.new
197
+ user.expects(:expire_association_cache)
198
+ account.stubs(:user).returns user
199
+ account.save
200
+ end
201
+ end
202
+
203
+ context "without a user" do
204
+ it "should not hit expire_association_cache on save" do
205
+ account = Account.create
206
+ obj = mock "object"
207
+ obj.stubs(:nil?).returns true
208
+ account.stubs(:user).returns obj
209
+ obj.expects(:expire_association_cache).never
210
+ account.expire_account_cache
211
+ end
212
+
213
+ end
214
+
193
215
  end
194
216
 
195
217
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_cacheable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-26 00:00:00.000000000 Z
12
+ date: 2013-07-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -29,30 +29,30 @@ dependencies:
29
29
  name: rspec
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - '='
33
33
  - !ruby/object:Gem::Version
34
- version: '0'
34
+ version: '2.8'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - '='
40
40
  - !ruby/object:Gem::Version
41
- version: '0'
41
+ version: '2.8'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: mocha
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '>='
46
+ - - '='
47
47
  - !ruby/object:Gem::Version
48
- version: '0'
48
+ version: 0.10.5
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - '>='
53
+ - - '='
54
54
  - !ruby/object:Gem::Version
55
- version: '0'
55
+ version: 0.10.5
56
56
  description: a simple cache implementation based on activerecord
57
57
  email:
58
58
  - flyerhzm@gmail.com