counter_culture 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +44 -43
- data/VERSION +1 -1
- data/counter_culture.gemspec +5 -5
- data/spec/counter_culture_spec.rb +25 -0
- data/spec/models/company.rb +1 -0
- data/spec/models/user.rb +4 -1
- data/spec/schema.rb +2 -0
- metadata +5 -5
data/Gemfile
CHANGED
@@ -6,7 +6,7 @@ source "http://rubygems.org"
|
|
6
6
|
# Add dependencies to develop your gem here.
|
7
7
|
# Include everything needed to run rake, tests, features, etc.
|
8
8
|
group :development, :test do
|
9
|
-
gem "rails"
|
9
|
+
gem "rails", '>= 3.1.0'
|
10
10
|
gem "rspec", "~> 2.10.0"
|
11
11
|
gem "after_commit_action"
|
12
12
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,79 +1,79 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
actionmailer (3.2.
|
5
|
-
actionpack (= 3.2.
|
4
|
+
actionmailer (3.2.10)
|
5
|
+
actionpack (= 3.2.10)
|
6
6
|
mail (~> 2.4.4)
|
7
|
-
actionpack (3.2.
|
8
|
-
activemodel (= 3.2.
|
9
|
-
activesupport (= 3.2.
|
7
|
+
actionpack (3.2.10)
|
8
|
+
activemodel (= 3.2.10)
|
9
|
+
activesupport (= 3.2.10)
|
10
10
|
builder (~> 3.0.0)
|
11
11
|
erubis (~> 2.7.0)
|
12
|
-
journey (~> 1.0.
|
12
|
+
journey (~> 1.0.4)
|
13
13
|
rack (~> 1.4.0)
|
14
14
|
rack-cache (~> 1.2)
|
15
15
|
rack-test (~> 0.6.1)
|
16
|
-
sprockets (~> 2.1
|
17
|
-
activemodel (3.2.
|
18
|
-
activesupport (= 3.2.
|
16
|
+
sprockets (~> 2.2.1)
|
17
|
+
activemodel (3.2.10)
|
18
|
+
activesupport (= 3.2.10)
|
19
19
|
builder (~> 3.0.0)
|
20
|
-
activerecord (3.2.
|
21
|
-
activemodel (= 3.2.
|
22
|
-
activesupport (= 3.2.
|
20
|
+
activerecord (3.2.10)
|
21
|
+
activemodel (= 3.2.10)
|
22
|
+
activesupport (= 3.2.10)
|
23
23
|
arel (~> 3.0.2)
|
24
24
|
tzinfo (~> 0.3.29)
|
25
|
-
activeresource (3.2.
|
26
|
-
activemodel (= 3.2.
|
27
|
-
activesupport (= 3.2.
|
28
|
-
activesupport (3.2.
|
25
|
+
activeresource (3.2.10)
|
26
|
+
activemodel (= 3.2.10)
|
27
|
+
activesupport (= 3.2.10)
|
28
|
+
activesupport (3.2.10)
|
29
29
|
i18n (~> 0.6)
|
30
30
|
multi_json (~> 1.0)
|
31
31
|
after_commit_action (0.1.3)
|
32
32
|
activerecord (>= 3.0.0)
|
33
33
|
arel (3.0.2)
|
34
|
-
builder (3.0.
|
34
|
+
builder (3.0.4)
|
35
35
|
diff-lcs (1.1.3)
|
36
36
|
erubis (2.7.0)
|
37
37
|
git (1.2.5)
|
38
38
|
hike (1.2.1)
|
39
|
-
i18n (0.6.
|
40
|
-
jeweler (1.8.
|
39
|
+
i18n (0.6.1)
|
40
|
+
jeweler (1.8.4)
|
41
41
|
bundler (~> 1.0)
|
42
42
|
git (>= 1.2.5)
|
43
43
|
rake
|
44
44
|
rdoc
|
45
|
-
journey (1.0.
|
46
|
-
json (1.7.
|
45
|
+
journey (1.0.4)
|
46
|
+
json (1.7.6)
|
47
47
|
mail (2.4.4)
|
48
48
|
i18n (>= 0.4.0)
|
49
49
|
mime-types (~> 1.16)
|
50
50
|
treetop (~> 1.4.8)
|
51
|
-
mime-types (1.
|
52
|
-
multi_json (1.
|
51
|
+
mime-types (1.19)
|
52
|
+
multi_json (1.5.0)
|
53
53
|
polyglot (0.3.3)
|
54
|
-
rack (1.4.
|
54
|
+
rack (1.4.3)
|
55
55
|
rack-cache (1.2)
|
56
56
|
rack (>= 0.4)
|
57
57
|
rack-ssl (1.3.2)
|
58
58
|
rack
|
59
|
-
rack-test (0.6.
|
59
|
+
rack-test (0.6.2)
|
60
60
|
rack (>= 1.0)
|
61
|
-
rails (3.2.
|
62
|
-
actionmailer (= 3.2.
|
63
|
-
actionpack (= 3.2.
|
64
|
-
activerecord (= 3.2.
|
65
|
-
activeresource (= 3.2.
|
66
|
-
activesupport (= 3.2.
|
61
|
+
rails (3.2.10)
|
62
|
+
actionmailer (= 3.2.10)
|
63
|
+
actionpack (= 3.2.10)
|
64
|
+
activerecord (= 3.2.10)
|
65
|
+
activeresource (= 3.2.10)
|
66
|
+
activesupport (= 3.2.10)
|
67
67
|
bundler (~> 1.0)
|
68
|
-
railties (= 3.2.
|
69
|
-
railties (3.2.
|
70
|
-
actionpack (= 3.2.
|
71
|
-
activesupport (= 3.2.
|
68
|
+
railties (= 3.2.10)
|
69
|
+
railties (3.2.10)
|
70
|
+
actionpack (= 3.2.10)
|
71
|
+
activesupport (= 3.2.10)
|
72
72
|
rack-ssl (~> 1.3.2)
|
73
73
|
rake (>= 0.8.7)
|
74
74
|
rdoc (~> 3.4)
|
75
|
-
thor (
|
76
|
-
rake (0.
|
75
|
+
thor (>= 0.14.6, < 2.0)
|
76
|
+
rake (10.0.3)
|
77
77
|
rdoc (3.12)
|
78
78
|
json (~> 1.4)
|
79
79
|
rspec (2.10.0)
|
@@ -83,19 +83,20 @@ GEM
|
|
83
83
|
rspec-core (2.10.1)
|
84
84
|
rspec-expectations (2.10.0)
|
85
85
|
diff-lcs (~> 1.1.3)
|
86
|
-
rspec-extra-formatters (0.
|
86
|
+
rspec-extra-formatters (1.0.0)
|
87
87
|
rspec-mocks (2.10.1)
|
88
|
-
sprockets (2.
|
88
|
+
sprockets (2.2.2)
|
89
89
|
hike (~> 1.2)
|
90
|
+
multi_json (~> 1.0)
|
90
91
|
rack (~> 1.0)
|
91
92
|
tilt (~> 1.1, != 1.3.0)
|
92
93
|
sqlite3 (1.3.6)
|
93
|
-
thor (0.
|
94
|
+
thor (0.16.0)
|
94
95
|
tilt (1.3.3)
|
95
|
-
treetop (1.4.
|
96
|
+
treetop (1.4.12)
|
96
97
|
polyglot
|
97
98
|
polyglot (>= 0.3.1)
|
98
|
-
tzinfo (0.3.
|
99
|
+
tzinfo (0.3.35)
|
99
100
|
|
100
101
|
PLATFORMS
|
101
102
|
ruby
|
@@ -104,7 +105,7 @@ DEPENDENCIES
|
|
104
105
|
after_commit_action
|
105
106
|
bundler (~> 1.2.0.pre)
|
106
107
|
jeweler (~> 1.8.3)
|
107
|
-
rails
|
108
|
+
rails (>= 3.1.0)
|
108
109
|
rdoc (~> 3.12)
|
109
110
|
rspec (~> 2.10.0)
|
110
111
|
rspec-extra-formatters
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.9
|
data/counter_culture.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "counter_culture"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.9"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Magnus von Koeller"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2013-01-08"
|
13
13
|
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."
|
14
14
|
s.email = "magnus@vonkoeller.de"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -97,7 +97,7 @@ Gem::Specification.new do |s|
|
|
97
97
|
s.specification_version = 3
|
98
98
|
|
99
99
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
100
|
-
s.add_development_dependency(%q<rails>, [">= 0"])
|
100
|
+
s.add_development_dependency(%q<rails>, [">= 3.1.0"])
|
101
101
|
s.add_development_dependency(%q<rspec>, ["~> 2.10.0"])
|
102
102
|
s.add_development_dependency(%q<after_commit_action>, [">= 0"])
|
103
103
|
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
@@ -105,7 +105,7 @@ Gem::Specification.new do |s|
|
|
105
105
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
106
106
|
s.add_runtime_dependency(%q<after_commit_action>, ["~> 0.1.3"])
|
107
107
|
else
|
108
|
-
s.add_dependency(%q<rails>, [">= 0"])
|
108
|
+
s.add_dependency(%q<rails>, [">= 3.1.0"])
|
109
109
|
s.add_dependency(%q<rspec>, ["~> 2.10.0"])
|
110
110
|
s.add_dependency(%q<after_commit_action>, [">= 0"])
|
111
111
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
@@ -114,7 +114,7 @@ Gem::Specification.new do |s|
|
|
114
114
|
s.add_dependency(%q<after_commit_action>, ["~> 0.1.3"])
|
115
115
|
end
|
116
116
|
else
|
117
|
-
s.add_dependency(%q<rails>, [">= 0"])
|
117
|
+
s.add_dependency(%q<rails>, [">= 3.1.0"])
|
118
118
|
s.add_dependency(%q<rspec>, ["~> 2.10.0"])
|
119
119
|
s.add_dependency(%q<after_commit_action>, [">= 0"])
|
120
120
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
@@ -861,6 +861,31 @@ describe "CounterCulture" do
|
|
861
861
|
user.using_count.should == 1
|
862
862
|
user.tried_count.should == 1
|
863
863
|
end
|
864
|
+
|
865
|
+
it "should work correctly for relationships with custom names" do
|
866
|
+
company = Company.create
|
867
|
+
user1 = User.create :manages_company_id => company.id
|
868
|
+
|
869
|
+
company.reload
|
870
|
+
company.managers_count.should == 1
|
871
|
+
|
872
|
+
user2 = User.create :manages_company_id => company.id
|
873
|
+
|
874
|
+
company.reload
|
875
|
+
company.managers_count.should == 2
|
876
|
+
|
877
|
+
user2.destroy
|
878
|
+
|
879
|
+
company.reload
|
880
|
+
company.managers_count.should == 1
|
881
|
+
|
882
|
+
company2 = Company.create
|
883
|
+
user1.manages_company_id = company2.id
|
884
|
+
user1.save!
|
885
|
+
|
886
|
+
company.reload
|
887
|
+
company.managers_count.should == 0
|
888
|
+
end
|
864
889
|
|
865
890
|
describe "#previous_model" do
|
866
891
|
let(:user){User.create :name => "John Smith", :company_id => 1}
|
data/spec/models/company.rb
CHANGED
data/spec/models/user.rb
CHANGED
data/spec/schema.rb
CHANGED
@@ -19,6 +19,7 @@ ActiveRecord::Schema.define(:version => 20120522160158) do
|
|
19
19
|
t.integer "reviews_count", :default => 0, :null => false
|
20
20
|
t.integer "using_count", :default => 0, :null => false
|
21
21
|
t.integer "tried_count", :default => 0, :null => false
|
22
|
+
t.integer "managers_count", :default => 0, :null => false
|
22
23
|
end
|
23
24
|
|
24
25
|
create_table "industries", :force => true do |t|
|
@@ -45,6 +46,7 @@ ActiveRecord::Schema.define(:version => 20120522160158) do
|
|
45
46
|
create_table "users", :force => true do |t|
|
46
47
|
t.string "name"
|
47
48
|
t.integer "company_id"
|
49
|
+
t.integer "manages_company_id"
|
48
50
|
t.integer "reviews_count", :default => 0, :null => false
|
49
51
|
t.integer "using_count", :default => 0, :null => false
|
50
52
|
t.integer "tried_count", :default => 0, :null => false
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 3.1.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 3.1.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rspec
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -218,7 +218,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
218
218
|
version: '0'
|
219
219
|
segments:
|
220
220
|
- 0
|
221
|
-
hash:
|
221
|
+
hash: 1797196708173178324
|
222
222
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
223
223
|
none: false
|
224
224
|
requirements:
|