ar-resque-counter-cache 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -19,9 +19,9 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_dependency "activerecord", "~> 3.
|
22
|
+
s.add_dependency "activerecord", "~> 3.2"
|
23
23
|
s.add_dependency "resque", "~> 1.0"
|
24
|
-
s.add_dependency "resque-lock-timeout", "~> 0.
|
24
|
+
s.add_dependency "resque-lock-timeout", "~> 0.4"
|
25
25
|
|
26
26
|
s.add_development_dependency "rspec", "~> 2.4.0"
|
27
27
|
s.add_development_dependency "sqlite3-ruby", "~> 1.3.3"
|
@@ -69,6 +69,11 @@ module ArResqueCounterCache
|
|
69
69
|
if options[:async_counter_cache]
|
70
70
|
add_async_counter_cache_callbacks(reflection)
|
71
71
|
end
|
72
|
+
# At this point the standard counter cache callbacks will not be added;
|
73
|
+
# however, we need the `:counter_cache` option to be present so that
|
74
|
+
# `ActiveRecord::Base.reset_counters` works correctly (as of
|
75
|
+
# activerecord 3.2.9).
|
76
|
+
options[:counter_cache] = true
|
72
77
|
reflection
|
73
78
|
end
|
74
79
|
|
@@ -7,15 +7,42 @@ describe ArResqueCounterCache::ActiveRecord do
|
|
7
7
|
subject { User.create(:name => "Susan") }
|
8
8
|
|
9
9
|
it "should increment" do
|
10
|
-
ArResqueCounterCache::IncrementCountersWorker.
|
10
|
+
ArResqueCounterCache::IncrementCountersWorker.
|
11
|
+
should_receive(:cache_and_enqueue).
|
12
|
+
with("User", subject.id, "posts_count", :increment)
|
11
13
|
subject.posts.create(:body => "I have a cat!")
|
12
14
|
end
|
13
15
|
|
14
16
|
it "should increment" do
|
15
17
|
ArResqueCounterCache::IncrementCountersWorker.stub(:cache_and_enqueue)
|
16
18
|
post = subject.posts.create(:body => "I have a cat!")
|
17
|
-
ArResqueCounterCache::IncrementCountersWorker.
|
19
|
+
ArResqueCounterCache::IncrementCountersWorker.
|
20
|
+
should_receive(:cache_and_enqueue).
|
21
|
+
with("User", subject.id, "posts_count", :decrement)
|
18
22
|
post.destroy
|
19
23
|
end
|
20
24
|
end
|
25
|
+
|
26
|
+
context "normal counter cache methods" do
|
27
|
+
|
28
|
+
let(:user) { User.create(:name => "Bob") }
|
29
|
+
|
30
|
+
before do
|
31
|
+
ArResqueCounterCache::IncrementCountersWorker.stub(:cache_and_enqueue)
|
32
|
+
user.posts.create(:body => "Foo")
|
33
|
+
user.posts.create(:body => "Bar")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should allow reset_counters" do
|
37
|
+
User.reset_counters(user.id, :posts)
|
38
|
+
user.reload
|
39
|
+
user.posts_count.should eq(2)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should allow update_counters" do
|
43
|
+
User.update_counters(user.id, :posts_count => 10)
|
44
|
+
user.reload
|
45
|
+
user.posts_count.should eq(10)
|
46
|
+
end
|
47
|
+
end
|
21
48
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ar-resque-counter-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,27 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '3.
|
21
|
+
version: '3.2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.2'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: resque
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
@@ -32,21 +37,31 @@ dependencies:
|
|
32
37
|
version: '1.0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: resque-lock-timeout
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
42
52
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.
|
53
|
+
version: '0.4'
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.4'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: rspec
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ~>
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: 2.4.0
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.4.0
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: sqlite3-ruby
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ~>
|
@@ -65,7 +85,12 @@ dependencies:
|
|
65
85
|
version: 1.3.3
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.3.3
|
69
94
|
description: Increment ActiveRecord's counter cache column asynchronously using Resque
|
70
95
|
(and resque-lock-timeout).
|
71
96
|
email:
|
@@ -109,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
134
|
version: '0'
|
110
135
|
requirements: []
|
111
136
|
rubyforge_project: ar-resque-counter-cache
|
112
|
-
rubygems_version: 1.8.
|
137
|
+
rubygems_version: 1.8.24
|
113
138
|
signing_key:
|
114
139
|
specification_version: 3
|
115
140
|
summary: Increment ActiveRecord's counter cache column asynchronously using Resque
|