bullet 4.1.4 → 4.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bullet (4.1.4)
4
+ bullet (4.1.5)
5
5
  uniform_notifier (~> 1.0.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bullet (4.1.4)
4
+ bullet (4.1.5)
5
5
  uniform_notifier (~> 1.0.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bullet (4.1.4)
4
+ bullet (4.1.5)
5
5
  uniform_notifier (~> 1.0.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bullet (4.1.4)
4
+ bullet (4.1.5)
5
5
  uniform_notifier (~> 1.0.0)
6
6
 
7
7
  GEM
@@ -45,7 +45,9 @@ module Bullet
45
45
  alias_method :origin_set_relation, :set_relation
46
46
 
47
47
  def set_relation(name, relation)
48
- Bullet::Detector::NPlusOneQuery.call_association(self, name)
48
+ if relation && relation.metadata.macro !~ /embed/
49
+ Bullet::Detector::NPlusOneQuery.call_association(self, name)
50
+ end
49
51
  origin_set_relation(name, relation)
50
52
  end
51
53
  end
@@ -44,7 +44,9 @@ module Bullet
44
44
  alias_method :origin_set_relation, :set_relation
45
45
 
46
46
  def set_relation(name, relation)
47
- Bullet::Detector::NPlusOneQuery.call_association(self, name)
47
+ if relation && relation.metadata.macro !~ /embed/
48
+ Bullet::Detector::NPlusOneQuery.call_association(self, name)
49
+ end
48
50
  origin_set_relation(name, relation)
49
51
  end
50
52
  end
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Bullet
3
- VERSION = "4.1.4"
3
+ VERSION = "4.1.5"
4
4
  end
@@ -11,6 +11,20 @@ if mongoid?
11
11
  Mongoid::IdentityMap.clear
12
12
  end
13
13
 
14
+ context 'embeds_many' do
15
+ context "posts => users" do
16
+ it "should detect nothing" do
17
+ Mongoid::Post.all.each do |post|
18
+ post.users.map(&:name)
19
+ end
20
+ Bullet::Detector::UnusedEagerAssociation.check_unused_preload_associations
21
+ Bullet::Detector::Association.should_not be_has_unused_preload_associations
22
+
23
+ Bullet::Detector::Association.should be_completely_preloading_associations
24
+ end
25
+ end
26
+ end
27
+
14
28
  context 'has_many' do
15
29
  context "posts => comments" do
16
30
  it "should detect non preload posts => comments" do
@@ -4,5 +4,7 @@ class Mongoid::Post
4
4
  has_many :comments, :class_name => "Mongoid::Comment"
5
5
  belongs_to :category, :class_name => "Mongoid::Category"
6
6
 
7
+ embeds_many :users, :class_name => "Mongoid::User"
8
+
7
9
  scope :preload_comments, lambda { includes(:comments) }
8
10
  end
@@ -0,0 +1,3 @@
1
+ class Mongoid::User
2
+ include Mongoid::Document
3
+ end
@@ -8,6 +8,10 @@ module Support
8
8
  post1a = category1.posts.create(:name => 'like first')
9
9
  post2 = category2.posts.create(:name => 'second')
10
10
 
11
+ post1.users << Mongoid::User.create(:name => 'first')
12
+ post1.users << Mongoid::User.create(:name => 'another')
13
+ post2.users << Mongoid::User.create(:name => 'second')
14
+
11
15
  comment1 = post1.comments.create(:name => 'first')
12
16
  comment2 = post1.comments.create(:name => 'first2')
13
17
  comment3 = post1.comments.create(:name => 'first3')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.4
4
+ version: 4.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-23 00:00:00.000000000 Z
12
+ date: 2012-07-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: uniform_notifier
16
- requirement: &70278160365200 !ruby/object:Gem::Requirement
16
+ requirement: &70299719166880 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 1.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70278160365200
24
+ version_requirements: *70299719166880
25
25
  description: A rails plugin to kill N+1 queries and unused eager loading.
26
26
  email:
27
27
  - flyerhzm@gmail.com
@@ -119,6 +119,7 @@ files:
119
119
  - spec/models/mongoid/company.rb
120
120
  - spec/models/mongoid/entry.rb
121
121
  - spec/models/mongoid/post.rb
122
+ - spec/models/mongoid/user.rb
122
123
  - spec/models/newspaper.rb
123
124
  - spec/models/page.rb
124
125
  - spec/models/person.rb
@@ -151,7 +152,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
152
  version: '0'
152
153
  segments:
153
154
  - 0
154
- hash: 107640970782381372
155
+ hash: 938107111431995273
155
156
  required_rubygems_version: !ruby/object:Gem::Requirement
156
157
  none: false
157
158
  requirements:
@@ -205,6 +206,7 @@ test_files:
205
206
  - spec/models/mongoid/company.rb
206
207
  - spec/models/mongoid/entry.rb
207
208
  - spec/models/mongoid/post.rb
209
+ - spec/models/mongoid/user.rb
208
210
  - spec/models/newspaper.rb
209
211
  - spec/models/page.rb
210
212
  - spec/models/person.rb