counter_culture 0.1.30 → 0.1.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/Gemfile +2 -1
- data/Gemfile.lock +4 -2
- data/VERSION +1 -1
- data/counter_culture.gemspec +10 -7
- data/lib/counter_culture.rb +6 -2
- data/spec/counter_culture_spec.rb +14 -3
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5768633c82c0cda2df6b2f4b213eef15e6f57a2a
|
4
|
+
data.tar.gz: b4e1cfdf54ebe4bdcbb224968f9f4cb80c93138a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c5faff89fb5e8fbf0a3c983f6d0da2bdb3a0aa46a246a51d1a6012495fea76b0a4a2141bb77111a21b34a44de0f5110187643e202ea482a3323b872be75fb4c
|
7
|
+
data.tar.gz: 1b94ac39d665d0acc1b0e6784cc12954125383777709b9fedc5016c569615fccd0e0337707d81228793be12f03005831127177d91f246245702e398d0b5c5d47
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
## 0.1.
|
1
|
+
## 0.1.31 (March 7, 2015)
|
2
|
+
|
3
|
+
Bugfixes:
|
4
|
+
- Avoid issue with has_and_belongs_to_many and transactions by using new after_commit_action version (fixes #88)
|
5
|
+
|
6
|
+
## 0.1.30 (February 10, 2015)
|
2
7
|
|
3
8
|
Bugfixes:
|
4
9
|
- Correctly use custom relation primary keys (fixes #93)
|
data/Gemfile
CHANGED
@@ -3,8 +3,9 @@ source "https://rubygems.org"
|
|
3
3
|
# Example:
|
4
4
|
# gem "activesupport", ">= 2.3.5"
|
5
5
|
|
6
|
-
gem "after_commit_action", "~> 0.
|
6
|
+
gem "after_commit_action", "~> 1.0.0"
|
7
7
|
gem "activerecord", ">= 3.0.0"
|
8
|
+
gem "activesupport", ">= 3.0.0"
|
8
9
|
|
9
10
|
# Add dependencies to develop your gem here.
|
10
11
|
# Include everything needed to run rake, tests, features, etc.
|
data/Gemfile.lock
CHANGED
@@ -28,8 +28,9 @@ GEM
|
|
28
28
|
thread_safe (~> 0.1)
|
29
29
|
tzinfo (~> 1.1)
|
30
30
|
addressable (2.3.6)
|
31
|
-
after_commit_action (0.
|
31
|
+
after_commit_action (1.0.0)
|
32
32
|
activerecord (>= 3.0.0)
|
33
|
+
activesupport (>= 3.0.0)
|
33
34
|
arel (5.0.1.20140414130214)
|
34
35
|
awesome_print (1.2.0)
|
35
36
|
builder (3.2.2)
|
@@ -131,7 +132,8 @@ PLATFORMS
|
|
131
132
|
|
132
133
|
DEPENDENCIES
|
133
134
|
activerecord (>= 3.0.0)
|
134
|
-
|
135
|
+
activesupport (>= 3.0.0)
|
136
|
+
after_commit_action (~> 1.0.0)
|
135
137
|
awesome_print
|
136
138
|
bundler (>= 1.2.0)
|
137
139
|
database_cleaner (>= 1.1.1)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.31
|
data/counter_culture.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: counter_culture 0.1.
|
5
|
+
# stub: counter_culture 0.1.31 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "counter_culture"
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.31"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Magnus von Koeller"]
|
14
|
-
s.date = "2015-
|
14
|
+
s.date = "2015-03-08"
|
15
15
|
s.description = "counter_culture provides turbo-charged counter caches that are kept up-to-date not just on create and destroy, that support multiple levels of indirection through relationships, allow dynamic column names and that avoid deadlocks by updating in the after_commit callback."
|
16
16
|
s.email = "magnus@vonkoeller.de"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -108,15 +108,16 @@ Gem::Specification.new do |s|
|
|
108
108
|
]
|
109
109
|
s.homepage = "http://github.com/bestvendor/counter_culture"
|
110
110
|
s.licenses = ["MIT"]
|
111
|
-
s.rubygems_version = "2.
|
111
|
+
s.rubygems_version = "2.4.3"
|
112
112
|
s.summary = "Turbo-charged counter caches for your Rails app."
|
113
113
|
|
114
114
|
if s.respond_to? :specification_version then
|
115
115
|
s.specification_version = 4
|
116
116
|
|
117
117
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
118
|
-
s.add_runtime_dependency(%q<after_commit_action>, ["~> 0.
|
118
|
+
s.add_runtime_dependency(%q<after_commit_action>, ["~> 1.0.0"])
|
119
119
|
s.add_runtime_dependency(%q<activerecord>, [">= 3.0.0"])
|
120
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 3.0.0"])
|
120
121
|
s.add_development_dependency(%q<rake>, [">= 0"])
|
121
122
|
s.add_development_dependency(%q<rails>, [">= 3.1.0"])
|
122
123
|
s.add_development_dependency(%q<rspec>, ["~> 2.10.0"])
|
@@ -125,8 +126,9 @@ Gem::Specification.new do |s|
|
|
125
126
|
s.add_development_dependency(%q<bundler>, [">= 1.2.0"])
|
126
127
|
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
127
128
|
else
|
128
|
-
s.add_dependency(%q<after_commit_action>, ["~> 0.
|
129
|
+
s.add_dependency(%q<after_commit_action>, ["~> 1.0.0"])
|
129
130
|
s.add_dependency(%q<activerecord>, [">= 3.0.0"])
|
131
|
+
s.add_dependency(%q<activesupport>, [">= 3.0.0"])
|
130
132
|
s.add_dependency(%q<rake>, [">= 0"])
|
131
133
|
s.add_dependency(%q<rails>, [">= 3.1.0"])
|
132
134
|
s.add_dependency(%q<rspec>, ["~> 2.10.0"])
|
@@ -136,8 +138,9 @@ Gem::Specification.new do |s|
|
|
136
138
|
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
137
139
|
end
|
138
140
|
else
|
139
|
-
s.add_dependency(%q<after_commit_action>, ["~> 0.
|
141
|
+
s.add_dependency(%q<after_commit_action>, ["~> 1.0.0"])
|
140
142
|
s.add_dependency(%q<activerecord>, [">= 3.0.0"])
|
143
|
+
s.add_dependency(%q<activesupport>, [">= 3.0.0"])
|
141
144
|
s.add_dependency(%q<rake>, [">= 0"])
|
142
145
|
s.add_dependency(%q<rails>, [">= 3.1.0"])
|
143
146
|
s.add_dependency(%q<rspec>, ["~> 2.10.0"])
|
data/lib/counter_culture.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
require 'after_commit_action'
|
2
|
+
require 'active_support/concern'
|
2
3
|
|
3
4
|
module CounterCulture
|
4
5
|
|
5
6
|
module ActiveRecord
|
7
|
+
extend ActiveSupport::Concern
|
6
8
|
|
7
|
-
|
9
|
+
included do
|
8
10
|
# also add class methods to ActiveRecord::Base
|
9
|
-
|
11
|
+
extend ClassMethods
|
10
12
|
end
|
11
13
|
|
12
14
|
module ClassMethods
|
@@ -15,6 +17,8 @@ module CounterCulture
|
|
15
17
|
|
16
18
|
# called to configure counter caches
|
17
19
|
def counter_culture(relation, options = {})
|
20
|
+
include AfterCommitAction
|
21
|
+
|
18
22
|
unless @after_commit_counter_cache
|
19
23
|
# initialize callbacks only once
|
20
24
|
after_create :_update_counts_after_create
|
@@ -28,7 +28,7 @@ describe "CounterCulture" do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
|
31
|
-
it "should use relation foreign_key correctly"
|
31
|
+
it "should use relation foreign_key correctly" do
|
32
32
|
post = AnotherPost.new
|
33
33
|
comment = post.comments.build
|
34
34
|
comment.comment = 'Comment'
|
@@ -37,7 +37,7 @@ describe "CounterCulture" do
|
|
37
37
|
post.another_post_comments_count.should == 1
|
38
38
|
end
|
39
39
|
|
40
|
-
it "should fix counts using relation foreign_key correctly"
|
40
|
+
it "should fix counts using relation foreign_key correctly" do
|
41
41
|
post = AnotherPost.new
|
42
42
|
comment = post.comments.build
|
43
43
|
comment.comment = 'Comment'
|
@@ -849,6 +849,17 @@ describe "CounterCulture" do
|
|
849
849
|
Category.all {|category| category.products_count.should == 0 }
|
850
850
|
end
|
851
851
|
|
852
|
+
it "should not report correct counts when fix_counts is called" do
|
853
|
+
user1 = User.create
|
854
|
+
user2 = User.create
|
855
|
+
|
856
|
+
review1 = Review.create user_id: user1.id, product: Product.create
|
857
|
+
review2 = Review.create user_id: user2.id, product: Product.create
|
858
|
+
|
859
|
+
user1.update_columns reviews_count: 2
|
860
|
+
|
861
|
+
Review.counter_culture_fix_counts(skip_unsupported: true).should == [{ entity: 'User', id: user1.id, what: 'reviews_count', right: 1, wrong: 2 }]
|
862
|
+
end
|
852
863
|
|
853
864
|
it "should fix a simple counter cache correctly" do
|
854
865
|
user = User.create
|
@@ -1263,7 +1274,7 @@ describe "CounterCulture" do
|
|
1263
1274
|
user.reviews_count.should == 2
|
1264
1275
|
end
|
1265
1276
|
|
1266
|
-
it "should use relation primary_key correctly"
|
1277
|
+
it "should use relation primary_key correctly" do
|
1267
1278
|
subcateg = Subcateg.create :subcat_id => Subcateg::SUBCAT_1
|
1268
1279
|
post = Post.new
|
1269
1280
|
post.subcateg = subcateg
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: counter_culture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Magnus von Koeller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: after_commit_action
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 1.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 1.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 3.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.0.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.0.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -253,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
253
267
|
version: '0'
|
254
268
|
requirements: []
|
255
269
|
rubyforge_project:
|
256
|
-
rubygems_version: 2.
|
270
|
+
rubygems_version: 2.4.3
|
257
271
|
signing_key:
|
258
272
|
specification_version: 4
|
259
273
|
summary: Turbo-charged counter caches for your Rails app.
|