activerecord-precount 0.6.1 → 0.6.2

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
  SHA1:
3
- metadata.gz: b261414eec5a1fd723fb2fcea8cbe708c48415ca
4
- data.tar.gz: 1d522f1cb7b9a7f0ac94d479feed434805d3077f
3
+ metadata.gz: c92657e5f11805aecb44010c1df4fe3974bf05da
4
+ data.tar.gz: 60838e0e6fcea0079f0d008ccc4424697675006f
5
5
  SHA512:
6
- metadata.gz: 9ddc79eeb3385aa2be6a1973c5e1bb11dba1fe123e3e9e6064fb3c16445922ff8273d8268a0ca37a8801b31fa9edd3cb5f70c091f5f3d23efa8fa2d4fde7915e
7
- data.tar.gz: 4340c6a29f8040a154d1f6d6c5a401064efc60bfab6ec654c808da6a2e58fc804c834507d8c2d35229034ead2dc72340e85218eaa31fd053f91d7a9a3d59c99a
6
+ metadata.gz: b93b4d140152d202018ea73a66b80a34bc3c55ee38a81d3ee4bb2d721ddcbd509d45aff9446278b0513c4c925979b4eef2258d50524d44b4b5664a1aa827f960
7
+ data.tar.gz: 65a1f4826a8686dec6e64873e3b8760c55a3a8bed687ec906f3897d09116792cdec13578d8b5e6c4a531404e099cea8f7e37f7e8e2e1d8e771e18881acae7db3
@@ -1,4 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'rails', '5.0.0.rc1'
3
+ gem 'rails', '5.0.0'
4
4
  gemspec path: '..'
@@ -28,6 +28,7 @@ require "active_support/lazy_load_hooks"
28
28
  # * collection_proxy_extension: Fallback to eager-loaded values when foo.count is called
29
29
  #
30
30
  ActiveSupport.on_load(:active_record) do
31
+ require "active_record/precount/autosave_association_extension"
31
32
  require "active_record/precount/base_extension"
32
33
  require "active_record/precount/collection_proxy_extension"
33
34
  require "active_record/precount/has_many_extension"
@@ -0,0 +1,14 @@
1
+ module ActiveRecord
2
+ module Precount
3
+ module AutosaveAssociationExtension
4
+ private
5
+
6
+ def save_belongs_to_association(reflection)
7
+ return if reflection.is_a? ActiveRecord::Reflection::CountLoaderReflection
8
+ super(reflection)
9
+ end
10
+ end
11
+ end
12
+
13
+ Base.prepend(Precount::AutosaveAssociationExtension)
14
+ end
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Precount
3
- VERSION = "0.6.1"
3
+ VERSION = "0.6.2"
4
4
  end
5
5
  end
@@ -0,0 +1,26 @@
1
+ require 'cases/helper'
2
+
3
+ class AutosaveAssociationBugReproductionTest < ActiveRecord::CountLoader::TestCase
4
+ def setup
5
+ tweets_count.times do |i|
6
+ tweet = Tweet.create
7
+ i.times do |j|
8
+ Favorite.create(tweet: tweet, user_id: j + 1)
9
+ end
10
+ end
11
+ end
12
+
13
+ def teardown
14
+ [Tweet, Favorite].each(&:delete_all)
15
+ end
16
+
17
+ def tweets_count
18
+ 3
19
+ end
20
+
21
+ def test_bug_with_save_belongs_to_association_method_fixed
22
+ tweet = Tweet.first
23
+ tweet.my_favorites_count
24
+ assert_equal(true, tweet.save!)
25
+ end
26
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-precount
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-04 00:00:00.000000000 Z
11
+ date: 2016-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -205,6 +205,7 @@ files:
205
205
  - ci/Gemfile.activerecord-5.0.x
206
206
  - ci/travis.rb
207
207
  - lib/active_record/precount.rb
208
+ - lib/active_record/precount/autosave_association_extension.rb
208
209
  - lib/active_record/precount/base_extension.rb
209
210
  - lib/active_record/precount/collection_proxy_extension.rb
210
211
  - lib/active_record/precount/count_loader_builder.rb
@@ -278,6 +279,7 @@ files:
278
279
  - sample/public/robots.txt
279
280
  - sample/vendor/assets/javascripts/.keep
280
281
  - sample/vendor/assets/stylesheets/.keep
282
+ - test/cases/associations/autosave_association_bug_reproduction_test.rb
281
283
  - test/cases/associations/eager_count_test.rb
282
284
  - test/cases/associations/eager_load_test.rb
283
285
  - test/cases/associations/includes_test.rb