counter_culture 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -1
- data/CHANGELOG.md +5 -1
- data/Gemfile +11 -1
- data/Gemfile.lock +90 -78
- data/VERSION +1 -1
- data/counter_culture.gemspec +7 -8
- data/lib/counter_culture/reconciler.rb +1 -6
- data/spec/counter_culture_spec.rb +9 -17
- data/spec/models/categ.rb +5 -0
- data/spec/models/company.rb +1 -3
- data/spec/models/subcateg.rb +5 -0
- data/spec/models/user.rb +11 -2
- data/spec/rails_app/config/application.rb +3 -1
- data/spec/rails_app/config/environments/test.rb +0 -1
- data/spec/schema.rb +0 -11
- data/test_rails_versions.sh +9 -0
- metadata +6 -7
- data/spec/models/company_access_level.rb +0 -4
- data/spec/models/recruiter.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 843f3db902028680dae427c6d905dd62a00af619
|
4
|
+
data.tar.gz: 86485d9f16f5bd3741ba409c64f86bd1021201a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7f863f03585d732c8d3c91da8036ef00c82d85368185587841a59cfdeec1b14726ea67eff092ff2d6434a00463d2464409649a0b37a3db42ef42689535be4f4
|
7
|
+
data.tar.gz: 1d518b4c9a480090d4aaf435cbbe9faba1bff362e3f683fe20f14e1071d3f79f152d9408c3af1a87f5d306caf004059630ecd2b55316e30f45732d32e45ed8cd
|
data/.travis.yml
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- "2.1.10"
|
4
3
|
- "2.2.5"
|
5
4
|
- "2.3.1"
|
5
|
+
env:
|
6
|
+
- "RAILS_VERSION=3.2.0"
|
7
|
+
- "RAILS_VERSION=4.0.0"
|
8
|
+
- "RAILS_VERSION=4.1.0"
|
9
|
+
- "RAILS_VERSION=4.2.0"
|
10
|
+
- "RAILS_VERSION=5.0.0"
|
11
|
+
install:
|
12
|
+
- bundle update
|
6
13
|
script: TRAVIS=true bundle exec rake spec
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 1.3.0 (February 21, 2017)
|
2
|
+
Removed features:
|
3
|
+
- Removed support for `has_one`; this did not work properly. If you need this, consider adding the `counter_culture` call on the model with the `belongs_to` instead.
|
4
|
+
|
1
5
|
## 1.2.0 (February 21, 2017)
|
2
6
|
|
3
7
|
New features:
|
@@ -11,7 +15,7 @@ Bugfixes:
|
|
11
15
|
## 1.1.0 (December 23, 2016)
|
12
16
|
|
13
17
|
Improvements:
|
14
|
-
- Support for has_one associations
|
18
|
+
- Support for `has_one` associations
|
15
19
|
|
16
20
|
## 1.0.0 (November 15, 2016)
|
17
21
|
|
data/Gemfile
CHANGED
@@ -11,7 +11,17 @@ gem "activesupport", ">= 3.0.0"
|
|
11
11
|
# Include everything needed to run rake, tests, features, etc.
|
12
12
|
group :development, :test do
|
13
13
|
gem "rake"
|
14
|
-
|
14
|
+
|
15
|
+
rails = case ENV["RAILS_VERSION"]
|
16
|
+
when "master"
|
17
|
+
{github: "rails/rails"}
|
18
|
+
when nil, ""
|
19
|
+
">= 3.1.0"
|
20
|
+
else
|
21
|
+
"~> #{ENV["RAILS_VERSION"]}"
|
22
|
+
end
|
23
|
+
gem "rails", rails
|
24
|
+
|
15
25
|
gem "rspec", "~> 3.0"
|
16
26
|
gem "awesome_print"
|
17
27
|
gem "timecop"
|
data/Gemfile.lock
CHANGED
@@ -1,53 +1,56 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
actionpack (=
|
6
|
-
|
7
|
-
|
4
|
+
actioncable (5.0.1)
|
5
|
+
actionpack (= 5.0.1)
|
6
|
+
nio4r (~> 1.2)
|
7
|
+
websocket-driver (~> 0.6.1)
|
8
|
+
actionmailer (5.0.1)
|
9
|
+
actionpack (= 5.0.1)
|
10
|
+
actionview (= 5.0.1)
|
11
|
+
activejob (= 5.0.1)
|
8
12
|
mail (~> 2.5, >= 2.5.4)
|
9
|
-
rails-dom-testing (~>
|
10
|
-
actionpack (
|
11
|
-
actionview (=
|
12
|
-
activesupport (=
|
13
|
-
rack (~>
|
14
|
-
rack-test (~> 0.6.
|
15
|
-
rails-dom-testing (~>
|
13
|
+
rails-dom-testing (~> 2.0)
|
14
|
+
actionpack (5.0.1)
|
15
|
+
actionview (= 5.0.1)
|
16
|
+
activesupport (= 5.0.1)
|
17
|
+
rack (~> 2.0)
|
18
|
+
rack-test (~> 0.6.3)
|
19
|
+
rails-dom-testing (~> 2.0)
|
16
20
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
17
|
-
actionview (
|
18
|
-
activesupport (=
|
21
|
+
actionview (5.0.1)
|
22
|
+
activesupport (= 5.0.1)
|
19
23
|
builder (~> 3.1)
|
20
24
|
erubis (~> 2.7.0)
|
21
|
-
rails-dom-testing (~>
|
25
|
+
rails-dom-testing (~> 2.0)
|
22
26
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
23
|
-
activejob (
|
24
|
-
activesupport (=
|
25
|
-
globalid (>= 0.3.
|
26
|
-
activemodel (
|
27
|
-
activesupport (=
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
activejob (5.0.1)
|
28
|
+
activesupport (= 5.0.1)
|
29
|
+
globalid (>= 0.3.6)
|
30
|
+
activemodel (5.0.1)
|
31
|
+
activesupport (= 5.0.1)
|
32
|
+
activerecord (5.0.1)
|
33
|
+
activemodel (= 5.0.1)
|
34
|
+
activesupport (= 5.0.1)
|
35
|
+
arel (~> 7.0)
|
36
|
+
activesupport (5.0.1)
|
37
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
34
38
|
i18n (~> 0.7)
|
35
|
-
json (~> 1.7, >= 1.7.7)
|
36
39
|
minitest (~> 5.1)
|
37
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
38
40
|
tzinfo (~> 1.1)
|
39
41
|
addressable (2.5.0)
|
40
42
|
public_suffix (~> 2.0, >= 2.0.2)
|
41
|
-
after_commit_action (1.0.
|
43
|
+
after_commit_action (1.0.1)
|
42
44
|
activerecord (>= 3.0.0)
|
43
45
|
activesupport (>= 3.0.0)
|
44
|
-
arel (
|
45
|
-
awesome_print (1.
|
46
|
-
builder (3.2.
|
47
|
-
|
46
|
+
arel (7.1.4)
|
47
|
+
awesome_print (1.7.0)
|
48
|
+
builder (3.2.3)
|
49
|
+
concurrent-ruby (1.0.4)
|
50
|
+
database_cleaner (1.5.3)
|
48
51
|
descendants_tracker (0.0.4)
|
49
52
|
thread_safe (~> 0.3, >= 0.3.1)
|
50
|
-
diff-lcs (1.
|
53
|
+
diff-lcs (1.3)
|
51
54
|
erubis (2.7.0)
|
52
55
|
faraday (0.9.2)
|
53
56
|
multipart-post (>= 1.2, < 3)
|
@@ -60,70 +63,75 @@ GEM
|
|
60
63
|
multi_json (>= 1.7.5, < 2.0)
|
61
64
|
nokogiri (~> 1.6.0)
|
62
65
|
oauth2
|
63
|
-
globalid (0.3.
|
66
|
+
globalid (0.3.7)
|
64
67
|
activesupport (>= 4.1.0)
|
65
|
-
hashie (3.
|
68
|
+
hashie (3.5.3)
|
66
69
|
highline (1.7.8)
|
67
|
-
i18n (0.
|
68
|
-
jeweler (2.
|
70
|
+
i18n (0.8.0)
|
71
|
+
jeweler (2.3.3)
|
69
72
|
builder
|
70
73
|
bundler (>= 1.0)
|
71
74
|
git (>= 1.2.5)
|
72
75
|
github_api (~> 0.11.0)
|
73
76
|
highline (>= 1.6.15)
|
74
77
|
nokogiri (>= 1.5.10)
|
78
|
+
psych (~> 2.2)
|
75
79
|
rake
|
76
80
|
rdoc
|
77
|
-
|
78
|
-
json (1.8.
|
81
|
+
semver2
|
82
|
+
json (1.8.6)
|
79
83
|
jwt (1.5.6)
|
80
84
|
loofah (2.0.3)
|
81
85
|
nokogiri (>= 1.5.9)
|
82
|
-
mail (2.6.
|
83
|
-
mime-types (>= 1.16, <
|
84
|
-
|
86
|
+
mail (2.6.4)
|
87
|
+
mime-types (>= 1.16, < 4)
|
88
|
+
method_source (0.8.2)
|
89
|
+
mime-types (3.1)
|
90
|
+
mime-types-data (~> 3.2015)
|
91
|
+
mime-types-data (3.2016.0521)
|
85
92
|
mini_portile2 (2.1.0)
|
86
|
-
minitest (5.
|
93
|
+
minitest (5.10.1)
|
87
94
|
multi_json (1.12.1)
|
88
|
-
multi_xml (0.
|
95
|
+
multi_xml (0.6.0)
|
89
96
|
multipart-post (2.0.0)
|
97
|
+
nio4r (1.2.1)
|
90
98
|
nokogiri (1.6.8.1)
|
91
99
|
mini_portile2 (~> 2.1.0)
|
92
|
-
oauth2 (1.
|
93
|
-
faraday (>= 0.8, < 0.
|
100
|
+
oauth2 (1.3.0)
|
101
|
+
faraday (>= 0.8, < 0.11)
|
94
102
|
jwt (~> 1.0)
|
95
103
|
multi_json (~> 1.3)
|
96
104
|
multi_xml (~> 0.5)
|
97
105
|
rack (>= 1.2, < 3)
|
98
|
-
|
99
|
-
|
106
|
+
psych (2.2.2)
|
107
|
+
public_suffix (2.0.5)
|
108
|
+
rack (2.0.1)
|
100
109
|
rack-test (0.6.3)
|
101
110
|
rack (>= 1.0)
|
102
|
-
rails (
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
111
|
+
rails (5.0.1)
|
112
|
+
actioncable (= 5.0.1)
|
113
|
+
actionmailer (= 5.0.1)
|
114
|
+
actionpack (= 5.0.1)
|
115
|
+
actionview (= 5.0.1)
|
116
|
+
activejob (= 5.0.1)
|
117
|
+
activemodel (= 5.0.1)
|
118
|
+
activerecord (= 5.0.1)
|
119
|
+
activesupport (= 5.0.1)
|
110
120
|
bundler (>= 1.3.0, < 2.0)
|
111
|
-
railties (=
|
112
|
-
sprockets-rails
|
113
|
-
rails-
|
114
|
-
activesupport (>= 4.2.0.
|
115
|
-
|
116
|
-
|
117
|
-
nokogiri (~> 1.6.0)
|
118
|
-
rails-deprecated_sanitizer (>= 1.0.1)
|
119
|
-
rails-html-sanitizer (1.0.2)
|
121
|
+
railties (= 5.0.1)
|
122
|
+
sprockets-rails (>= 2.0.0)
|
123
|
+
rails-dom-testing (2.0.2)
|
124
|
+
activesupport (>= 4.2.0, < 6.0)
|
125
|
+
nokogiri (~> 1.6)
|
126
|
+
rails-html-sanitizer (1.0.3)
|
120
127
|
loofah (~> 2.0)
|
121
|
-
railties (
|
122
|
-
actionpack (=
|
123
|
-
activesupport (=
|
128
|
+
railties (5.0.1)
|
129
|
+
actionpack (= 5.0.1)
|
130
|
+
activesupport (= 5.0.1)
|
131
|
+
method_source
|
124
132
|
rake (>= 0.8.7)
|
125
133
|
thor (>= 0.18.1, < 2.0)
|
126
|
-
rake (
|
134
|
+
rake (12.0.0)
|
127
135
|
rdoc (3.12.2)
|
128
136
|
json (~> 1.4)
|
129
137
|
rspec (3.5.0)
|
@@ -140,19 +148,23 @@ GEM
|
|
140
148
|
diff-lcs (>= 1.2.0, < 2.0)
|
141
149
|
rspec-support (~> 3.5.0)
|
142
150
|
rspec-support (3.5.0)
|
143
|
-
|
144
|
-
sprockets (3.
|
151
|
+
semver2 (3.4.2)
|
152
|
+
sprockets (3.7.1)
|
153
|
+
concurrent-ruby (~> 1.0)
|
145
154
|
rack (> 1, < 3)
|
146
|
-
sprockets-rails (2.
|
147
|
-
actionpack (>=
|
148
|
-
activesupport (>=
|
149
|
-
sprockets (>=
|
150
|
-
sqlite3 (1.3.
|
151
|
-
thor (0.19.
|
155
|
+
sprockets-rails (3.2.0)
|
156
|
+
actionpack (>= 4.0)
|
157
|
+
activesupport (>= 4.0)
|
158
|
+
sprockets (>= 3.0.0)
|
159
|
+
sqlite3 (1.3.13)
|
160
|
+
thor (0.19.4)
|
152
161
|
thread_safe (0.3.5)
|
153
162
|
timecop (0.8.1)
|
154
163
|
tzinfo (1.2.2)
|
155
164
|
thread_safe (~> 0.1)
|
165
|
+
websocket-driver (0.6.5)
|
166
|
+
websocket-extensions (>= 0.1.0)
|
167
|
+
websocket-extensions (0.1.2)
|
156
168
|
|
157
169
|
PLATFORMS
|
158
170
|
ruby
|
@@ -165,7 +177,7 @@ DEPENDENCIES
|
|
165
177
|
bundler (>= 1.2.0)
|
166
178
|
database_cleaner (>= 1.1.1)
|
167
179
|
jeweler (~> 2.1)
|
168
|
-
rails (
|
180
|
+
rails (~> 5.0.0)
|
169
181
|
rake
|
170
182
|
rdoc (~> 3.12)
|
171
183
|
rspec (~> 3.0)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
data/counter_culture.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
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 1.
|
5
|
+
# stub: counter_culture 1.3.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "counter_culture"
|
9
|
-
s.version = "1.
|
9
|
+
s.version = "1.3.0"
|
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"]
|
@@ -44,7 +44,6 @@ Gem::Specification.new do |s|
|
|
44
44
|
"spec/models/categ.rb",
|
45
45
|
"spec/models/category.rb",
|
46
46
|
"spec/models/company.rb",
|
47
|
-
"spec/models/company_access_level.rb",
|
48
47
|
"spec/models/conditional_dependent.rb",
|
49
48
|
"spec/models/conditional_main.rb",
|
50
49
|
"spec/models/has_string_id.rb",
|
@@ -53,7 +52,6 @@ Gem::Specification.new do |s|
|
|
53
52
|
"spec/models/post.rb",
|
54
53
|
"spec/models/post_comment.rb",
|
55
54
|
"spec/models/product.rb",
|
56
|
-
"spec/models/recruiter.rb",
|
57
55
|
"spec/models/review.rb",
|
58
56
|
"spec/models/simple_dependent.rb",
|
59
57
|
"spec/models/simple_main.rb",
|
@@ -111,7 +109,8 @@ Gem::Specification.new do |s|
|
|
111
109
|
"spec/rails_app/vendor/assets/stylesheets/.gitkeep",
|
112
110
|
"spec/rails_app/vendor/plugins/.gitkeep",
|
113
111
|
"spec/schema.rb",
|
114
|
-
"spec/spec_helper.rb"
|
112
|
+
"spec/spec_helper.rb",
|
113
|
+
"test_rails_versions.sh"
|
115
114
|
]
|
116
115
|
s.homepage = "http://github.com/magnusvk/counter_culture"
|
117
116
|
s.licenses = ["MIT"]
|
@@ -126,7 +125,7 @@ Gem::Specification.new do |s|
|
|
126
125
|
s.add_runtime_dependency(%q<activerecord>, [">= 3.0.0"])
|
127
126
|
s.add_runtime_dependency(%q<activesupport>, [">= 3.0.0"])
|
128
127
|
s.add_development_dependency(%q<rake>, [">= 0"])
|
129
|
-
s.add_development_dependency(%q<rails>, ["
|
128
|
+
s.add_development_dependency(%q<rails>, ["~> 5.0.0"])
|
130
129
|
s.add_development_dependency(%q<rspec>, ["~> 3.0"])
|
131
130
|
s.add_development_dependency(%q<awesome_print>, [">= 0"])
|
132
131
|
s.add_development_dependency(%q<timecop>, [">= 0"])
|
@@ -138,7 +137,7 @@ Gem::Specification.new do |s|
|
|
138
137
|
s.add_dependency(%q<activerecord>, [">= 3.0.0"])
|
139
138
|
s.add_dependency(%q<activesupport>, [">= 3.0.0"])
|
140
139
|
s.add_dependency(%q<rake>, [">= 0"])
|
141
|
-
s.add_dependency(%q<rails>, ["
|
140
|
+
s.add_dependency(%q<rails>, ["~> 5.0.0"])
|
142
141
|
s.add_dependency(%q<rspec>, ["~> 3.0"])
|
143
142
|
s.add_dependency(%q<awesome_print>, [">= 0"])
|
144
143
|
s.add_dependency(%q<timecop>, [">= 0"])
|
@@ -151,7 +150,7 @@ Gem::Specification.new do |s|
|
|
151
150
|
s.add_dependency(%q<activerecord>, [">= 3.0.0"])
|
152
151
|
s.add_dependency(%q<activesupport>, [">= 3.0.0"])
|
153
152
|
s.add_dependency(%q<rake>, [">= 0"])
|
154
|
-
s.add_dependency(%q<rails>, ["
|
153
|
+
s.add_dependency(%q<rails>, ["~> 5.0.0"])
|
155
154
|
s.add_dependency(%q<rspec>, ["~> 3.0"])
|
156
155
|
s.add_dependency(%q<awesome_print>, [">= 0"])
|
157
156
|
s.add_dependency(%q<timecop>, [">= 0"])
|
@@ -130,13 +130,8 @@ module CounterCulture
|
|
130
130
|
else
|
131
131
|
join_table_name = reflect.active_record.table_name
|
132
132
|
end
|
133
|
-
if reflect.has_one?
|
134
|
-
on_sql = "#{reflect.table_name}.#{reflect.foreign_key} = #{join_table_name}.#{reflect.association_primary_key}"
|
135
|
-
else
|
136
|
-
on_sql = "#{reflect.table_name}.#{reflect.association_primary_key} = #{join_table_name}.#{reflect.foreign_key}"
|
137
|
-
end
|
138
133
|
# join with alias to avoid ambiguous table name with self-referential models:
|
139
|
-
joins_sql = "LEFT JOIN #{reflect.active_record.table_name} AS #{join_table_name} ON #{
|
134
|
+
joins_sql = "LEFT JOIN #{reflect.active_record.table_name} AS #{join_table_name} ON #{reflect.table_name}.#{reflect.association_primary_key} = #{join_table_name}.#{reflect.foreign_key}"
|
140
135
|
# adds 'type' condition to JOIN clause if the current model is a child in a Single Table Inheritance
|
141
136
|
joins_sql = "#{joins_sql} AND #{reflect.active_record.table_name}.type IN ('#{model.name}')" if reflect.active_record.column_names.include?('type') && !model.descends_from_active_record?
|
142
137
|
joins_sql
|
@@ -1,8 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
require 'models/company'
|
4
|
-
require 'models/company_access_level'
|
5
|
-
require 'models/recruiter'
|
6
4
|
require 'models/industry'
|
7
5
|
require 'models/product'
|
8
6
|
require 'models/review'
|
@@ -942,7 +940,7 @@ describe "CounterCulture" do
|
|
942
940
|
review1 = Review.create user_id: user1.id, product: Product.create
|
943
941
|
review2 = Review.create user_id: user2.id, product: Product.create
|
944
942
|
|
945
|
-
user1.
|
943
|
+
user1.update_column :reviews_count, 2
|
946
944
|
|
947
945
|
expect(Review.counter_culture_fix_counts(skip_unsupported: true)).to eq([{ entity: 'User', id: user1.id, what: 'reviews_count', right: 1, wrong: 2 }])
|
948
946
|
end
|
@@ -1230,6 +1228,8 @@ describe "CounterCulture" do
|
|
1230
1228
|
end
|
1231
1229
|
|
1232
1230
|
it "should work correctly with string keys" do
|
1231
|
+
skip("Unsupported in this version of Rails") if Rails.version < "4.0.0"
|
1232
|
+
|
1233
1233
|
string_id = HasStringId.create(id: "1")
|
1234
1234
|
string_id2 = HasStringId.create(id: "abc")
|
1235
1235
|
|
@@ -1456,6 +1456,8 @@ describe "CounterCulture" do
|
|
1456
1456
|
end
|
1457
1457
|
|
1458
1458
|
it "should use primary key on counted records table correctly when fixing counts" do
|
1459
|
+
skip("Unsupported in this version of Rails") if Rails.version < "4.0.0"
|
1460
|
+
|
1459
1461
|
subcateg = Subcateg.create :subcat_id => Subcateg::SUBCAT_1
|
1460
1462
|
post = Post.new
|
1461
1463
|
post.subcateg = subcateg
|
@@ -1471,8 +1473,9 @@ describe "CounterCulture" do
|
|
1471
1473
|
expect(post.reload.comments_count).to eq(1)
|
1472
1474
|
end
|
1473
1475
|
|
1474
|
-
|
1475
1476
|
it "should use multi-level relation primary key on counter destination table correctly when fixing counts" do
|
1477
|
+
skip("Unsupported in this version of Rails") if Rails.version < "4.0.0"
|
1478
|
+
|
1476
1479
|
categ = Categ.create :cat_id => Categ::CAT_1
|
1477
1480
|
subcateg = Subcateg.new :subcat_id => Subcateg::SUBCAT_1
|
1478
1481
|
subcateg.categ = categ
|
@@ -1540,17 +1543,6 @@ describe "CounterCulture" do
|
|
1540
1543
|
expect(fixed.length).to eq(1)
|
1541
1544
|
expect(company.reload.children_count).to eq(1)
|
1542
1545
|
end
|
1543
|
-
|
1544
|
-
it "works with a has_one association" do
|
1545
|
-
company = Company.create!
|
1546
|
-
company.recruiters << Recruiter.create!
|
1547
|
-
expect(company.reload.recruiters_count).to eq(1)
|
1548
|
-
|
1549
|
-
company.update_columns(recruiters_count: 2)
|
1550
|
-
|
1551
|
-
Recruiter.counter_culture_fix_counts
|
1552
|
-
expect(company.reload.recruiters_count).to eq(1)
|
1553
|
-
end
|
1554
1546
|
end
|
1555
1547
|
|
1556
1548
|
describe "dynamic column names with totaling instead of counting" do
|
@@ -1582,8 +1574,8 @@ describe "CounterCulture" do
|
|
1582
1574
|
fixed = Transaction.counter_culture_fix_counts
|
1583
1575
|
expect(fixed.length).to eq(2)
|
1584
1576
|
expect(fixed).to eq([
|
1585
|
-
{:entity=>"Person", :id=>
|
1586
|
-
{:entity=>"Person", :id=>
|
1577
|
+
{:entity=>"Person", :id=>person.id, :what=>"money_earned_total", :wrong=>0, :right=>10},
|
1578
|
+
{:entity=>"Person", :id=>person.id, :what=>"money_spent_total", :wrong=>0, :right=>-20}
|
1587
1579
|
])
|
1588
1580
|
end
|
1589
1581
|
end
|
data/spec/models/categ.rb
CHANGED
data/spec/models/company.rb
CHANGED
@@ -6,8 +6,6 @@ class Company < ActiveRecord::Base
|
|
6
6
|
belongs_to :parent, :class_name => 'Company', :foreign_key => 'parent_id'
|
7
7
|
has_many :children, :class_name => 'Company', :foreign_key => 'parent_id'
|
8
8
|
|
9
|
-
has_many :company_access_levels
|
10
|
-
has_many :recruiters, through: :company_access_levels
|
11
|
-
|
12
9
|
counter_culture :parent, :column_name => :children_count
|
10
|
+
|
13
11
|
end
|
data/spec/models/subcateg.rb
CHANGED
data/spec/models/user.rb
CHANGED
@@ -11,9 +11,18 @@ class User < ActiveRecord::Base
|
|
11
11
|
|
12
12
|
default_scope do
|
13
13
|
if _default_scope_enabled
|
14
|
-
joins("LEFT OUTER JOIN companies")
|
14
|
+
query = joins("LEFT OUTER JOIN companies")
|
15
|
+
if Rails.version < "5.0.0"
|
16
|
+
query = query.uniq
|
17
|
+
else
|
18
|
+
query = query.distinct
|
19
|
+
end
|
15
20
|
else
|
16
|
-
|
21
|
+
if Rails.version < "4.0.0"
|
22
|
+
scoped
|
23
|
+
else
|
24
|
+
all
|
25
|
+
end
|
17
26
|
end
|
18
27
|
end
|
19
28
|
|
@@ -51,6 +51,8 @@ module RailsApp
|
|
51
51
|
config.assets.version = '1.0'
|
52
52
|
|
53
53
|
# Avoid deprecation warning
|
54
|
-
|
54
|
+
if Rails.version >= "4.2.0" && Rails.version < "5.0.0"
|
55
|
+
config.active_record.raise_in_transactional_callbacks = true
|
56
|
+
end
|
55
57
|
end
|
56
58
|
end
|
@@ -9,7 +9,6 @@ RailsApp::Application.configure do
|
|
9
9
|
|
10
10
|
# Configure static asset server for tests with Cache-Control for performance
|
11
11
|
config.serve_static_files = true
|
12
|
-
config.static_cache_control = "public, max-age=3600"
|
13
12
|
|
14
13
|
# Show full error reports and disable caching
|
15
14
|
config.consider_all_requests_local = true
|
data/spec/schema.rb
CHANGED
@@ -24,16 +24,10 @@ ActiveRecord::Schema.define(:version => 20120522160158) do
|
|
24
24
|
t.integer "review_approvals_count", :default => 0, :null => false
|
25
25
|
t.integer "parent_id"
|
26
26
|
t.integer "children_count", :default => 0, :null => false
|
27
|
-
t.integer "recruiters_count", :default => 0, :null => false
|
28
27
|
t.datetime "created_at"
|
29
28
|
t.datetime "updated_at"
|
30
29
|
end
|
31
30
|
|
32
|
-
create_table "company_access_levels", :force => true do |t|
|
33
|
-
t.integer "company_id"
|
34
|
-
t.integer "recruiter_id"
|
35
|
-
end
|
36
|
-
|
37
31
|
create_table "industries", :force => true do |t|
|
38
32
|
t.string "name"
|
39
33
|
t.integer "reviews_count", :default => 0, :null => false
|
@@ -70,11 +64,6 @@ ActiveRecord::Schema.define(:version => 20120522160158) do
|
|
70
64
|
t.datetime "updated_at"
|
71
65
|
end
|
72
66
|
|
73
|
-
create_table "recruiters", :force => true do |t|
|
74
|
-
t.datetime "created_at"
|
75
|
-
t.datetime "updated_at"
|
76
|
-
end
|
77
|
-
|
78
67
|
create_table "users", :force => true do |t|
|
79
68
|
t.string "name"
|
80
69
|
t.integer "company_id"
|
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: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Magnus von Koeller
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: rails
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 5.0.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 5.0.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -200,7 +200,6 @@ files:
|
|
200
200
|
- spec/models/categ.rb
|
201
201
|
- spec/models/category.rb
|
202
202
|
- spec/models/company.rb
|
203
|
-
- spec/models/company_access_level.rb
|
204
203
|
- spec/models/conditional_dependent.rb
|
205
204
|
- spec/models/conditional_main.rb
|
206
205
|
- spec/models/has_string_id.rb
|
@@ -209,7 +208,6 @@ files:
|
|
209
208
|
- spec/models/post.rb
|
210
209
|
- spec/models/post_comment.rb
|
211
210
|
- spec/models/product.rb
|
212
|
-
- spec/models/recruiter.rb
|
213
211
|
- spec/models/review.rb
|
214
212
|
- spec/models/simple_dependent.rb
|
215
213
|
- spec/models/simple_main.rb
|
@@ -268,6 +266,7 @@ files:
|
|
268
266
|
- spec/rails_app/vendor/plugins/.gitkeep
|
269
267
|
- spec/schema.rb
|
270
268
|
- spec/spec_helper.rb
|
269
|
+
- test_rails_versions.sh
|
271
270
|
homepage: http://github.com/magnusvk/counter_culture
|
272
271
|
licenses:
|
273
272
|
- MIT
|