bullet 2.3.1 → 4.0.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.
Files changed (54) hide show
  1. data/.travis.yml +5 -0
  2. data/Gemfile +3 -1
  3. data/Gemfile.lock +43 -32
  4. data/Gemfile.rails-2.3.14 +16 -0
  5. data/Gemfile.rails-2.3.14.lock +65 -0
  6. data/Gemfile.rails-3.0.12 +17 -0
  7. data/Gemfile.rails-3.0.12.lock +116 -0
  8. data/Gemfile.rails-3.1.4 +18 -0
  9. data/Gemfile.rails-3.1.4.lock +134 -0
  10. data/README.textile +5 -5
  11. data/lib/bullet.rb +15 -9
  12. data/lib/bullet/active_record2.rb +12 -0
  13. data/lib/bullet/active_record3.rb +12 -0
  14. data/lib/bullet/detector/association.rb +11 -12
  15. data/lib/bullet/detector/counter.rb +6 -6
  16. data/lib/bullet/detector/n_plus_one_query.rb +9 -9
  17. data/lib/bullet/detector/unused_eager_association.rb +9 -9
  18. data/lib/bullet/ext/object.rb +5 -0
  19. data/lib/bullet/ext/string.rb +5 -0
  20. data/lib/bullet/mongoid.rb +56 -0
  21. data/lib/bullet/registry/object.rb +4 -6
  22. data/lib/bullet/version.rb +1 -1
  23. data/spec/bullet/detector/association_spec.rb +14 -14
  24. data/spec/bullet/detector/counter_spec.rb +8 -9
  25. data/spec/bullet/detector/n_plus_one_query_spec.rb +22 -22
  26. data/spec/bullet/detector/unused_eager_association_spec.rb +7 -7
  27. data/spec/bullet/ext/object_spec.rb +20 -0
  28. data/spec/bullet/ext/string_spec.rb +13 -0
  29. data/spec/bullet/registry/object_spec.rb +4 -4
  30. data/spec/integration/association_spec.rb +463 -401
  31. data/spec/integration/counter_spec.rb +27 -25
  32. data/spec/integration/mongoid/association_spec.rb +276 -0
  33. data/spec/integration/rails2/association_spec.rb +593 -0
  34. data/spec/integration/rails2/counter_spec.rb +39 -0
  35. data/spec/models/mongoid/address.rb +5 -0
  36. data/spec/models/mongoid/category.rb +6 -0
  37. data/spec/models/mongoid/comment.rb +5 -0
  38. data/spec/models/mongoid/company.rb +5 -0
  39. data/spec/models/mongoid/entry.rb +5 -0
  40. data/spec/models/mongoid/post.rb +8 -0
  41. data/spec/models/post.rb +12 -6
  42. data/spec/spec_helper.rb +32 -8
  43. data/spec/support/bullet_ext.rb +1 -1
  44. data/spec/support/mongo_seed.rb +41 -0
  45. data/spec/support/{seed.rb → sqlite_seed.rb} +1 -22
  46. data/test.result +2293 -0
  47. metadata +42 -22
  48. data/spec/integration/association_for_chris_spec.rb +0 -37
  49. data/spec/integration/association_for_peschkaj_spec.rb +0 -26
  50. data/spec/models/contact.rb +0 -3
  51. data/spec/models/deal.rb +0 -4
  52. data/spec/models/email.rb +0 -3
  53. data/spec/models/hotel.rb +0 -4
  54. data/spec/models/location.rb +0 -3
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: 2.3.1
4
+ version: 4.0.0
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-04-02 00:00:00.000000000 Z
12
+ date: 2012-05-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: uniform_notifier
16
- requirement: &70233469813360 !ruby/object:Gem::Requirement
16
+ requirement: &70311383422560 !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: *70233469813360
24
+ version_requirements: *70311383422560
25
25
  description: A rails plugin to kill N+1 queries and unused eager loading.
26
26
  email:
27
27
  - flyerhzm@gmail.com
@@ -36,6 +36,12 @@ files:
36
36
  - .travis.yml
37
37
  - Gemfile
38
38
  - Gemfile.lock
39
+ - Gemfile.rails-2.3.14
40
+ - Gemfile.rails-2.3.14.lock
41
+ - Gemfile.rails-3.0.12
42
+ - Gemfile.rails-3.0.12.lock
43
+ - Gemfile.rails-3.1.4
44
+ - Gemfile.rails-3.1.4.lock
39
45
  - Guardfile
40
46
  - Hacking.textile
41
47
  - MIT-LICENSE
@@ -54,6 +60,9 @@ files:
54
60
  - lib/bullet/detector/counter.rb
55
61
  - lib/bullet/detector/n_plus_one_query.rb
56
62
  - lib/bullet/detector/unused_eager_association.rb
63
+ - lib/bullet/ext/object.rb
64
+ - lib/bullet/ext/string.rb
65
+ - lib/bullet/mongoid.rb
57
66
  - lib/bullet/notification.rb
58
67
  - lib/bullet/notification/base.rb
59
68
  - lib/bullet/notification/counter_cache.rb
@@ -73,6 +82,8 @@ files:
73
82
  - spec/bullet/detector/counter_spec.rb
74
83
  - spec/bullet/detector/n_plus_one_query_spec.rb
75
84
  - spec/bullet/detector/unused_eager_association_spec.rb
85
+ - spec/bullet/ext/object_spec.rb
86
+ - spec/bullet/ext/string_spec.rb
76
87
  - spec/bullet/notification/base_spec.rb
77
88
  - spec/bullet/notification/counter_cache_spec.rb
78
89
  - spec/bullet/notification/n_plus_one_query_spec.rb
@@ -82,10 +93,11 @@ files:
82
93
  - spec/bullet/registry/association_spec.rb
83
94
  - spec/bullet/registry/base_spec.rb
84
95
  - spec/bullet/registry/object_spec.rb
85
- - spec/integration/association_for_chris_spec.rb
86
- - spec/integration/association_for_peschkaj_spec.rb
87
96
  - spec/integration/association_spec.rb
88
97
  - spec/integration/counter_spec.rb
98
+ - spec/integration/mongoid/association_spec.rb
99
+ - spec/integration/rails2/association_spec.rb
100
+ - spec/integration/rails2/counter_spec.rb
89
101
  - spec/models/address.rb
90
102
  - spec/models/author.rb
91
103
  - spec/models/base_user.rb
@@ -94,16 +106,17 @@ files:
94
106
  - spec/models/client.rb
95
107
  - spec/models/comment.rb
96
108
  - spec/models/company.rb
97
- - spec/models/contact.rb
98
109
  - spec/models/country.rb
99
- - spec/models/deal.rb
100
110
  - spec/models/document.rb
101
- - spec/models/email.rb
102
111
  - spec/models/entry.rb
103
112
  - spec/models/firm.rb
104
113
  - spec/models/folder.rb
105
- - spec/models/hotel.rb
106
- - spec/models/location.rb
114
+ - spec/models/mongoid/address.rb
115
+ - spec/models/mongoid/category.rb
116
+ - spec/models/mongoid/comment.rb
117
+ - spec/models/mongoid/company.rb
118
+ - spec/models/mongoid/entry.rb
119
+ - spec/models/mongoid/post.rb
107
120
  - spec/models/newspaper.rb
108
121
  - spec/models/page.rb
109
122
  - spec/models/person.rb
@@ -117,9 +130,11 @@ files:
117
130
  - spec/models/writer.rb
118
131
  - spec/spec_helper.rb
119
132
  - spec/support/bullet_ext.rb
133
+ - spec/support/mongo_seed.rb
120
134
  - spec/support/rack_double.rb
121
- - spec/support/seed.rb
135
+ - spec/support/sqlite_seed.rb
122
136
  - tasks/bullet_tasks.rake
137
+ - test.result
123
138
  homepage: http://github.com/flyerhzm/bullet
124
139
  licenses: []
125
140
  post_install_message:
@@ -134,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
149
  version: '0'
135
150
  segments:
136
151
  - 0
137
- hash: 3928584312604954980
152
+ hash: -3387566190207483190
138
153
  required_rubygems_version: !ruby/object:Gem::Requirement
139
154
  none: false
140
155
  requirements:
@@ -143,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
158
  version: 1.3.6
144
159
  requirements: []
145
160
  rubyforge_project:
146
- rubygems_version: 1.8.17
161
+ rubygems_version: 1.8.15
147
162
  signing_key:
148
163
  specification_version: 3
149
164
  summary: A rails plugin to kill N+1 queries and unused eager loading.
@@ -153,6 +168,8 @@ test_files:
153
168
  - spec/bullet/detector/counter_spec.rb
154
169
  - spec/bullet/detector/n_plus_one_query_spec.rb
155
170
  - spec/bullet/detector/unused_eager_association_spec.rb
171
+ - spec/bullet/ext/object_spec.rb
172
+ - spec/bullet/ext/string_spec.rb
156
173
  - spec/bullet/notification/base_spec.rb
157
174
  - spec/bullet/notification/counter_cache_spec.rb
158
175
  - spec/bullet/notification/n_plus_one_query_spec.rb
@@ -162,10 +179,11 @@ test_files:
162
179
  - spec/bullet/registry/association_spec.rb
163
180
  - spec/bullet/registry/base_spec.rb
164
181
  - spec/bullet/registry/object_spec.rb
165
- - spec/integration/association_for_chris_spec.rb
166
- - spec/integration/association_for_peschkaj_spec.rb
167
182
  - spec/integration/association_spec.rb
168
183
  - spec/integration/counter_spec.rb
184
+ - spec/integration/mongoid/association_spec.rb
185
+ - spec/integration/rails2/association_spec.rb
186
+ - spec/integration/rails2/counter_spec.rb
169
187
  - spec/models/address.rb
170
188
  - spec/models/author.rb
171
189
  - spec/models/base_user.rb
@@ -174,16 +192,17 @@ test_files:
174
192
  - spec/models/client.rb
175
193
  - spec/models/comment.rb
176
194
  - spec/models/company.rb
177
- - spec/models/contact.rb
178
195
  - spec/models/country.rb
179
- - spec/models/deal.rb
180
196
  - spec/models/document.rb
181
- - spec/models/email.rb
182
197
  - spec/models/entry.rb
183
198
  - spec/models/firm.rb
184
199
  - spec/models/folder.rb
185
- - spec/models/hotel.rb
186
- - spec/models/location.rb
200
+ - spec/models/mongoid/address.rb
201
+ - spec/models/mongoid/category.rb
202
+ - spec/models/mongoid/comment.rb
203
+ - spec/models/mongoid/company.rb
204
+ - spec/models/mongoid/entry.rb
205
+ - spec/models/mongoid/post.rb
187
206
  - spec/models/newspaper.rb
188
207
  - spec/models/page.rb
189
208
  - spec/models/person.rb
@@ -197,5 +216,6 @@ test_files:
197
216
  - spec/models/writer.rb
198
217
  - spec/spec_helper.rb
199
218
  - spec/support/bullet_ext.rb
219
+ - spec/support/mongo_seed.rb
200
220
  - spec/support/rack_double.rb
201
- - spec/support/seed.rb
221
+ - spec/support/sqlite_seed.rb
@@ -1,37 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # This test is just used for http://github.com/flyerhzm/bullet/issues/#issue/14
4
- describe Bullet::Detector::Association do
5
- before(:each) do
6
- Bullet.clear
7
- Bullet.start_request
8
- end
9
-
10
- after(:each) do
11
- Bullet.end_request
12
- end
13
-
14
- describe "for chris" do
15
- it "should detect unpreload association from deal to hotel" do
16
- Deal.all.each do |deal|
17
- deal.hotel.location.name
18
- end
19
- Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Deal, :hotel)
20
- end
21
-
22
- it "should detect unpreload association from hotel to location" do
23
- Deal.includes(:hotel).each do |deal|
24
- deal.hotel.location.name
25
- end
26
- Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Hotel, :location)
27
- end
28
-
29
- it "should not detect unpreload association" do
30
- Deal.includes({:hotel => :location}).each do |deal|
31
- deal.hotel.location.name
32
- end
33
- Bullet::Detector::UnusedEagerAssociation.check_unused_preload_associations
34
- Bullet::Detector::Association.should_not be_has_unused_preload_associations
35
- end
36
- end
37
- end
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # This test is just used for http://github.com/flyerhzm/bullet/issues#issue/20
4
- describe Bullet::Detector::Association do
5
- before(:each) do
6
- Bullet.clear
7
- Bullet.start_request
8
- end
9
-
10
- after(:each) do
11
- Bullet.end_request
12
- end
13
-
14
- describe "for peschkaj" do
15
- it "should not detect unused preload associations" do
16
- category = Category.includes({:submissions => :user}).order("id DESC").find_by_name('first')
17
- category.submissions.map do |submission|
18
- submission.name
19
- submission.user.name
20
- end
21
- Bullet::Detector::UnusedEagerAssociation.check_unused_preload_associations
22
- Bullet::Detector::Association.should_not be_unused_preload_associations_for(Category, :submissions)
23
- Bullet::Detector::Association.should_not be_unused_preload_associations_for(Submission, :user)
24
- end
25
- end
26
- end
@@ -1,3 +0,0 @@
1
- class Contact < ActiveRecord::Base
2
- has_many :emails
3
- end
@@ -1,4 +0,0 @@
1
- class Deal < ActiveRecord::Base
2
- belongs_to :hotel
3
- has_one :location, :through => :hotel
4
- end
@@ -1,3 +0,0 @@
1
- class Email < ActiveRecord::Base
2
- belongs_to :contact
3
- end
@@ -1,4 +0,0 @@
1
- class Hotel < ActiveRecord::Base
2
- belongs_to :location
3
- has_many :deals
4
- end
@@ -1,3 +0,0 @@
1
- class Location < ActiveRecord::Base
2
- has_many :hotels
3
- end