Permalink
Browse files

+ make sure that dumped index files only contain unique ids per token…

… (thanks M. Below!)
  • Loading branch information...
1 parent db23549 commit 4d1915419a1c23a3c5831b8b6cda89ef516d6be2 @floere committed Nov 10, 2011
Showing with 15 additions and 3 deletions.
  1. +1 −0 server/lib/picky/bundle_indexing.rb
  2. +14 −3 server/spec/lib/indexing/bundle_spec.rb
@@ -109,6 +109,7 @@ def retrieve
prepared.retrieve do |id, token|
initialize_inverted_index_for token
self.inverted[token] << id.send(format)
+ self.inverted[token].uniq!
end
end
@@ -84,9 +84,20 @@
prepared.should_receive(:retrieve).once.and_yield ' 1234', :some_token
bundle.stub! :prepared => prepared
- @ary = stub :ary
- inverted = stub :inverted, :[] => @ary
- bundle.stub! :inverted => inverted
+ @ary = [1,1,1,2,3,3]
+ @inverted = stub :inverted, :[] => @ary
+ bundle.stub! :inverted => @inverted
+ end
+ context 'uniqueness' do
+ before(:each) do
+ @category.stub! :key_format => :to_i
+ @inverted = { :test => @ary }
+ end
+ it 'is correct' do
+ bundle.retrieve
+
+ bundle.inverted[:test].should == [1,2,3,1234]
+ end
end
context 'id key format' do
before(:each) do

0 comments on commit 4d19154

Please sign in to comment.