outoftime-sunspot 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/sunspot/search/hit.rb +4 -0
- data/lib/sunspot/search.rb +7 -9
- data/spec/api/search_retrieval_spec.rb +10 -0
- data/spec/mocks/mock_record.rb +7 -0
- metadata +2 -2
data/VERSION.yml
CHANGED
data/lib/sunspot/search/hit.rb
CHANGED
data/lib/sunspot/search.rb
CHANGED
@@ -159,16 +159,14 @@ module Sunspot
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def populate_hits! #:nodoc:
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
type_hit_hash[hit.class_name] << hit
|
166
|
-
id_hit_hash[hit.primary_key] = hit
|
162
|
+
id_hit_hash = Hash.new { |h, k| h[k] = {} }
|
163
|
+
hits.each do |hit|
|
164
|
+
id_hit_hash[hit.class_name][hit.primary_key] = hit
|
167
165
|
end
|
168
|
-
|
169
|
-
ids = hits.map { |hit| hit.primary_key }
|
170
|
-
|
171
|
-
hit = id_hit_hash[Adapters::InstanceAdapter.adapt(instance).id.to_s]
|
166
|
+
id_hit_hash.each_pair do |class_name, hits|
|
167
|
+
ids = hits.map { |id, hit| hit.primary_key }
|
168
|
+
data_accessor_for(Util.full_const_get(class_name)).load_all(ids).each do |instance|
|
169
|
+
hit = id_hit_hash[class_name][Adapters::InstanceAdapter.adapt(instance).id.to_s]
|
172
170
|
hit.instance = instance
|
173
171
|
end
|
174
172
|
end
|
@@ -15,6 +15,16 @@ describe 'retrieving search' do
|
|
15
15
|
session.search(Post).results.should == [post_2, post_1]
|
16
16
|
end
|
17
17
|
|
18
|
+
# This is a reduction of a crazy bug I found in production where some hits
|
19
|
+
# were inexplicably not being populated.
|
20
|
+
it 'properly loads results of multiple classes that have the same primary key' do
|
21
|
+
Post.reset!
|
22
|
+
Namespaced::Comment.reset!
|
23
|
+
results = [Post.new, Namespaced::Comment.new]
|
24
|
+
stub_results(*results)
|
25
|
+
session.search(Post, Namespaced::Comment).results.should == results
|
26
|
+
end
|
27
|
+
|
18
28
|
if ENV['USE_WILL_PAGINATE']
|
19
29
|
|
20
30
|
it 'should return search total as attribute of results if pagination is provided' do
|
data/spec/mocks/mock_record.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: outoftime-sunspot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mat Brown
|
@@ -12,7 +12,7 @@ autorequire:
|
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
14
|
|
15
|
-
date: 2009-08-
|
15
|
+
date: 2009-08-21 00:00:00 -07:00
|
16
16
|
default_executable:
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|