counter_culture 2.0.1 → 2.1.0
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 +4 -4
- data/README.md +1 -1
- data/VERSION +1 -1
- data/counter_culture.gemspec +5 -3
- data/lib/counter_culture/counter.rb +1 -1
- data/spec/counter_culture_spec.rb +19 -0
- data/spec/models/with_module/model1.rb +8 -0
- data/spec/models/with_module/model2.rb +7 -0
- data/spec/schema.rb +8 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eddddf9ccad9aca42b6b1cd53149c7bb03d7da3624dc85df00705acbe5f44c02
|
4
|
+
data.tar.gz: ba158099b8c8209f390be7e39aa257621e801d211f6c291412b21ca4f1afc56e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 917106835d1847c50fcba61c064d456a05db40ef12dabb000a4da1a8d508d5837db66234567ca688cd4e83faa75981597aa2c16650301027c78a58fddbd1e198
|
7
|
+
data.tar.gz: 9255cd93515ccc1177bccc12e3eadca029bb618cc6e2c0d17b96f44cacaab01222e2e9c4b7f64a5ae36db24ae9b0d94a263b152bdd88c67ba47e348419222902
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ Turbo-charged counter caches for your Rails app. Huge improvements over the Rail
|
|
7
7
|
* Supports dynamic column names, making it possible to split up the counter cache for different types of objects
|
8
8
|
* Can keep a running count, or a running total
|
9
9
|
|
10
|
-
Tested against Ruby 2.2.
|
10
|
+
Tested against Ruby 2.2.10, 2.3.7, 2.4.4 and 2.5.1 and against the latest patch releases of Rails 3.2, 4.0, 4.1, 4.2, 5.0, 5.1 and 5.2.
|
11
11
|
|
12
12
|
## Installation
|
13
13
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0
|
1
|
+
2.1.0
|
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 2.0
|
5
|
+
# stub: counter_culture 2.1.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "counter_culture".freeze
|
9
|
-
s.version = "2.0
|
9
|
+
s.version = "2.1.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Magnus von Koeller".freeze]
|
14
|
-
s.date = "2018-
|
14
|
+
s.date = "2018-10-19"
|
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.".freeze
|
16
16
|
s.email = "magnus@vonkoeller.de".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -66,6 +66,8 @@ Gem::Specification.new do |s|
|
|
66
66
|
"spec/models/transaction.rb",
|
67
67
|
"spec/models/twitter_review.rb",
|
68
68
|
"spec/models/user.rb",
|
69
|
+
"spec/models/with_module/model1.rb",
|
70
|
+
"spec/models/with_module/model2.rb",
|
69
71
|
"spec/rails_app/.gitignore",
|
70
72
|
"spec/rails_app/Gemfile",
|
71
73
|
"spec/rails_app/README.rdoc",
|
@@ -13,7 +13,7 @@ module CounterCulture
|
|
13
13
|
fail("execute_after_commit was removed; updates now run within the transaction")
|
14
14
|
end
|
15
15
|
|
16
|
-
@counter_cache_name = options.fetch(:column_name, "#{model.name.tableize}_count")
|
16
|
+
@counter_cache_name = options.fetch(:column_name, "#{model.name.demodulize.tableize}_count")
|
17
17
|
@column_names = options[:column_names]
|
18
18
|
@delta_column = options[:delta_column]
|
19
19
|
@foreign_key_values = options[:foreign_key_values]
|
@@ -26,6 +26,8 @@ require 'models/soft_delete_paranoia'
|
|
26
26
|
require 'models/conversation'
|
27
27
|
require 'models/candidate_profile'
|
28
28
|
require 'models/candidate'
|
29
|
+
require 'models/with_module/model1'
|
30
|
+
require 'models/with_module/model2'
|
29
31
|
|
30
32
|
require 'database_cleaner'
|
31
33
|
DatabaseCleaner.strategy = :deletion
|
@@ -2096,6 +2098,23 @@ describe "CounterCulture" do
|
|
2096
2098
|
end
|
2097
2099
|
end
|
2098
2100
|
|
2101
|
+
describe "with a module for the model" do
|
2102
|
+
it "works" do
|
2103
|
+
model2 = WithModule::Model2.create!
|
2104
|
+
5.times { WithModule::Model1.create!(model2: model2) }
|
2105
|
+
|
2106
|
+
model2.reload
|
2107
|
+
expect(model2.model1s_count).to eq(5)
|
2108
|
+
|
2109
|
+
model2.update_column(:model1s_count, -1)
|
2110
|
+
|
2111
|
+
WithModule::Model1.counter_culture_fix_counts
|
2112
|
+
|
2113
|
+
model2.reload
|
2114
|
+
expect(model2.model1s_count).to eq(5)
|
2115
|
+
end
|
2116
|
+
end
|
2117
|
+
|
2099
2118
|
private
|
2100
2119
|
def papertrail_supported_here?
|
2101
2120
|
return false if Rails.version < "5.0.0"
|
data/spec/schema.rb
CHANGED
@@ -230,4 +230,12 @@ ActiveRecord::Schema.define(:version => 20120522160158) do
|
|
230
230
|
t.datetime :created_at
|
231
231
|
end
|
232
232
|
add_index :versions, [:item_id, :item_type]
|
233
|
+
|
234
|
+
create_table :with_module_model1s, :force => true do |t|
|
235
|
+
t.integer :model2_id
|
236
|
+
end
|
237
|
+
|
238
|
+
create_table :with_module_model2s, :force => true do |t|
|
239
|
+
t.integer :model1s_count
|
240
|
+
end
|
233
241
|
end
|
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: 2.0
|
4
|
+
version: 2.1.0
|
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: 2018-
|
11
|
+
date: 2018-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: after_commit_action
|
@@ -264,6 +264,8 @@ files:
|
|
264
264
|
- spec/models/transaction.rb
|
265
265
|
- spec/models/twitter_review.rb
|
266
266
|
- spec/models/user.rb
|
267
|
+
- spec/models/with_module/model1.rb
|
268
|
+
- spec/models/with_module/model2.rb
|
267
269
|
- spec/rails_app/.gitignore
|
268
270
|
- spec/rails_app/Gemfile
|
269
271
|
- spec/rails_app/README.rdoc
|