counter_culture 2.1.0 → 2.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eddddf9ccad9aca42b6b1cd53149c7bb03d7da3624dc85df00705acbe5f44c02
4
- data.tar.gz: ba158099b8c8209f390be7e39aa257621e801d211f6c291412b21ca4f1afc56e
3
+ metadata.gz: 750074b917f0a0e9b7191aa948120ef09a1bc1496a949733aaf16d410656484d
4
+ data.tar.gz: 7d272b1c474a7a4201d1169e6116ad2b6946dcaba07abad814024a164d87e96c
5
5
  SHA512:
6
- metadata.gz: 917106835d1847c50fcba61c064d456a05db40ef12dabb000a4da1a8d508d5837db66234567ca688cd4e83faa75981597aa2c16650301027c78a58fddbd1e198
7
- data.tar.gz: 9255cd93515ccc1177bccc12e3eadca029bb618cc6e2c0d17b96f44cacaab01222e2e9c4b7f64a5ae36db24ae9b0d94a263b152bdd88c67ba47e348419222902
6
+ metadata.gz: 0f65dbd3b05fd218642e18a229afcd1dfb4db538d896d9b866bfc083dceb5585d1bfcb9333738d9e854a1c9c4275445391962f891f642e0ed4d21a2091d65e90
7
+ data.tar.gz: af264d88858d62892cf4c601c1367cb57da56c82accbe51297398f296cd9c286c60f2861279df1cb32c569cbe46494033e320da21b3ae484c2468e00dd7a929b
@@ -1,3 +1,13 @@
1
+ ## 2.1.1 (November 7, 2018)
2
+
3
+ Bugfixes:
4
+ - Don't double-decrement when discarding and then hard-destroying a record (#237)
5
+
6
+ ## 2.1.0 (October 19, 2018)
7
+
8
+ Bugfixes:
9
+ - Fix behavior with Models that are part of a module (ex: `Users::Admin`) (#234)
10
+
1
11
  ## 2.0.1 (August 19, 2018)
2
12
 
3
13
  Bugfixes:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 2.1.1
@@ -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.1.0 ruby lib
5
+ # stub: counter_culture 2.1.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "counter_culture".freeze
9
- s.version = "2.1.0"
9
+ s.version = "2.1.1"
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-10-19"
14
+ s.date = "2018-11-07"
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 = [
@@ -23,6 +23,8 @@ module CounterCulture
23
23
  before_destroy :_update_counts_after_destroy, if: -> (model) do
24
24
  if model.respond_to?(:paranoia_destroyed?)
25
25
  !model.paranoia_destroyed?
26
+ elsif defined?(Discard::Model) && model.class.include?(Discard::Model)
27
+ !model.discarded?
26
28
  else
27
29
  true
28
30
  end
@@ -1784,6 +1784,35 @@ describe "CounterCulture" do
1784
1784
  sd.undiscard
1785
1785
  expect(company.reload.soft_delete_discards_count).to eq(1)
1786
1786
  end
1787
+
1788
+ describe "when calling hard-destroy" do
1789
+ it "does not run destroy callback for discarded records" do
1790
+ skip("Unsupported in this version of Rails") if Rails.version < "4.2.0"
1791
+
1792
+ company = Company.create!
1793
+ sd = SoftDeleteDiscard.create!(company_id: company.id)
1794
+
1795
+ expect(company.reload.soft_delete_discards_count).to eq(1)
1796
+
1797
+ sd.discard
1798
+ expect(company.reload.soft_delete_discards_count).to eq(0)
1799
+
1800
+ sd.destroy
1801
+ expect(company.reload.soft_delete_discards_count).to eq(0)
1802
+ end
1803
+
1804
+ it "runs destroy callback for undiscarded records" do
1805
+ skip("Unsupported in this version of Rails") if Rails.version < "4.2.0"
1806
+
1807
+ company = Company.create!
1808
+ sd = SoftDeleteDiscard.create!(company_id: company.id)
1809
+
1810
+ expect(company.reload.soft_delete_discards_count).to eq(1)
1811
+
1812
+ sd.destroy
1813
+ expect(company.reload.soft_delete_discards_count).to eq(0)
1814
+ end
1815
+ end
1787
1816
  end
1788
1817
 
1789
1818
  describe "when using paranoia for soft deletes" do
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.1.0
4
+ version: 2.1.1
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-10-19 00:00:00.000000000 Z
11
+ date: 2018-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: after_commit_action