Permalink
Browse files

more than a hundred rows was causing the offline indexer to infinite …

…loop.
  • Loading branch information...
1 parent 1da7ac0 commit 0e6c9ca1e61e01f891bf54e6d0feab9b2fd11fb3 @jamesgolick committed Jan 26, 2010
Showing with 23 additions and 7 deletions.
  1. +1 −1 lib/friendly/indexer.rb
  2. +22 −6 spec/integration/offline_indexing_spec.rb
View
@@ -22,8 +22,8 @@ def initialize(datastore = Friendly.datastore, translator = Translator.new)
end
def populate(klass, index)
+ count = 0
loop do
- count = 0
rows = datastore.all(klass, Query.new(:offset! => count,
:limit! => objects_per_iteration,
:order! => :added_id.asc))
@@ -22,16 +22,32 @@ def self.table_name; "awesome_things"; end
@klass.indexes :name
@klass.create_tables!
- Friendly::Indexer.populate(@klass, :name)
end
- it "builds the missing index rows for all the rows in the doc table" do
- @klass.all(:name => "James").should == @jameses
+ describe "" do
+ before do
+ Friendly::Indexer.populate(@klass, :name)
+ end
+
+ it "builds the missing index rows for all the rows in the doc table" do
+ @klass.all(:name => "James").should == @jameses
+ end
+
+ it "ignores records that are already in the index" do
+ lambda {
+ Friendly::Indexer.populate(@klass, :name)
+ }.should_not raise_error
+ end
end
- it "ignores records that are already in the index" do
- lambda {
+ describe "with more than `Indexer.objects_per_iteration` objects" do
+ before do
+ Friendly::Indexer.objects_per_iteration = 1
Friendly::Indexer.populate(@klass, :name)
- }.should_not raise_error
+ end
+
+ it "builds the missing index rows for all the rows in the doc table" do
+ @klass.all(:name => "James").should == @jameses
+ end
end
end

0 comments on commit 0e6c9ca

Please sign in to comment.