bullet 4.12.0 → 4.13.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b201e99b1db5ea0ae016eb415b8bdcb2141a0321
4
- data.tar.gz: 072c423687b8482273549f30c2538edec5c3c03f
3
+ metadata.gz: e90d569b3150f0988aeb2f614513e4603f231a92
4
+ data.tar.gz: 8106c975d3aa193772e6146757c2f55144f8205e
5
5
  SHA512:
6
- metadata.gz: 624bfcc8a8f2044699d19e598729cba0bf858e054002b435a31cce643d1bc3834139dad14ea510ef573a31059ce13f4b5c1dd892404645cca8d77e47264db794
7
- data.tar.gz: ffaf8125f6797fd85b42be44f645e835796d623bc8b656662b8bd7387ac3b92882d4f2daaf2c50c04aced38113d7c96fbd8b3bdf631bd532c0a02663e221e1d1
6
+ metadata.gz: d7fdb81048632cf1c99bf42680ce5c78ef8f605be770088d2d7f623f25663fb1a00e8f860775175791b54245f1a610430372d7402b35e29b4a636148052ef0e6
7
+ data.tar.gz: 12518c2cafae4fa1db72215e3d6430c1781f82601176db91edf5b7246f52305a9991f37f522517e71af3d4435b5159589efbc25379694e38c76726cedd85ffc0
@@ -1,6 +1,10 @@
1
1
  # Next Release
2
2
 
3
- ## 4.12.0
3
+ ## 4.13.0 (07/19/2014)
4
+
5
+ * Support include? call on ar associations
6
+
7
+ ## 4.12.0 (07/13/2014)
4
8
 
5
9
  * Fix false n+1 queries caused by inversed objects.
6
10
  * Replace .id with .primary_key_value
@@ -103,6 +103,12 @@ module Bullet
103
103
  Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
104
104
  origin_empty?
105
105
  end
106
+
107
+ alias_method :origin_include?, :include?
108
+ def include?(object)
109
+ Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
110
+ origin_include?(object)
111
+ end
106
112
  end
107
113
 
108
114
  ::ActiveRecord::Associations::AssociationProxy.class_eval do
@@ -91,6 +91,12 @@ module Bullet
91
91
  Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
92
92
  origin_empty?
93
93
  end
94
+
95
+ alias_method :origin_include?, :include?
96
+ def include?(object)
97
+ Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
98
+ origin_include?(object)
99
+ end
94
100
  end
95
101
 
96
102
  ::ActiveRecord::Associations::SingularAssociation.class_eval do
@@ -91,6 +91,12 @@ module Bullet
91
91
  Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
92
92
  origin_empty?
93
93
  end
94
+
95
+ alias_method :origin_include?, :include?
96
+ def include?(object)
97
+ Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
98
+ origin_include?(object)
99
+ end
94
100
  end
95
101
 
96
102
  ::ActiveRecord::Associations::SingularAssociation.class_eval do
@@ -93,6 +93,12 @@ module Bullet
93
93
  Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
94
94
  origin_empty?
95
95
  end
96
+
97
+ alias_method :origin_include?, :include?
98
+ def include?(object)
99
+ Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
100
+ origin_include?(object)
101
+ end
96
102
  end
97
103
 
98
104
  ::ActiveRecord::Associations::SingularAssociation.class_eval do
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Bullet
3
- VERSION = "4.12.0"
3
+ VERSION = "4.13.0"
4
4
  end
@@ -61,6 +61,17 @@ if !mongoid? && active_record3?
61
61
 
62
62
  expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Post, :comments)
63
63
  end
64
+
65
+ it "should detect non preload post => comments with include?" do
66
+ comment = Comment.last
67
+ Post.all.each do |post|
68
+ post.comments.include?(comment)
69
+ end
70
+ Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
71
+ expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
72
+
73
+ expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Post, :comments)
74
+ end
64
75
  end
65
76
 
66
77
  context "category => posts => comments" do
@@ -61,6 +61,17 @@ if !mongoid? && active_record4?
61
61
 
62
62
  expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Post, :comments)
63
63
  end
64
+
65
+ it "should detect non preload post => comments with include?" do
66
+ comment = Comment.last
67
+ Post.all.each do |post|
68
+ post.comments.include?(comment)
69
+ end
70
+ Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
71
+ expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
72
+
73
+ expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Post, :comments)
74
+ end
64
75
  end
65
76
 
66
77
  context "category => posts => comments" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.12.0
4
+ version: 4.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-13 00:00:00.000000000 Z
11
+ date: 2014-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport