flyerhzm-bullet 1.5.7 → 1.5.8
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bullet.gemspec +1 -1
- data/lib/bullet/active_record.rb +5 -3
- data/lib/bullet/association.rb +1 -1
- data/spec/bullet_association_spec.rb +2 -4
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.5.
|
1
|
+
1.5.8
|
data/bullet.gemspec
CHANGED
data/lib/bullet/active_record.rb
CHANGED
@@ -31,7 +31,7 @@ module Bullet
|
|
31
31
|
records = [records].flatten.compact.uniq
|
32
32
|
return if records.empty?
|
33
33
|
records.each do |record|
|
34
|
-
Bullet::Association.
|
34
|
+
Bullet::Association.add_object_associations(record, associations)
|
35
35
|
end
|
36
36
|
Bullet::Association.add_eager_loadings(records, associations)
|
37
37
|
origin_preload_associations(records, associations, preload_options={})
|
@@ -50,10 +50,12 @@ module Bullet
|
|
50
50
|
alias_method :origin_find_with_associations, :find_with_associations
|
51
51
|
def find_with_associations(options)
|
52
52
|
records = origin_find_with_associations(options)
|
53
|
+
associations = merge_includes(scope(:find, :include), options[:include])
|
53
54
|
records.each do |record|
|
54
|
-
Bullet::Association.
|
55
|
+
Bullet::Association.add_object_associations(record, associations)
|
56
|
+
Bullet::Association.add_call_object_associations(record, associations)
|
55
57
|
end
|
56
|
-
Bullet::Association.add_eager_loadings(records,
|
58
|
+
Bullet::Association.add_eager_loadings(records, associations)
|
57
59
|
records
|
58
60
|
end
|
59
61
|
end
|
data/lib/bullet/association.rb
CHANGED
@@ -38,7 +38,7 @@ module Bullet
|
|
38
38
|
unique(unused_preload_associations[klazz])
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
41
|
+
def add_object_associations(object, associations)
|
42
42
|
object_associations[object] ||= []
|
43
43
|
object_associations[object] << associations
|
44
44
|
unique(object_associations[object])
|
@@ -255,12 +255,10 @@ describe Bullet::Association, 'has_many' do
|
|
255
255
|
end
|
256
256
|
|
257
257
|
it "should not be unused preload post => category" do
|
258
|
-
Post.in_category_name('first').all.
|
259
|
-
post.name
|
260
|
-
end
|
258
|
+
Post.in_category_name('first').all.collect(&:name)
|
261
259
|
Bullet::Association.should_not be_has_unpreload_associations
|
262
260
|
Bullet::Association.check_unused_preload_associations
|
263
|
-
Bullet::Association.
|
261
|
+
Bullet::Association.should_not be_has_unused_preload_associations
|
264
262
|
end
|
265
263
|
end
|
266
264
|
|