From bd29ca6cb7dcc9ffbd57ce4caf368bd07ff9d569 Mon Sep 17 00:00:00 2001 From: Florian Hanke Date: Tue, 5 Jul 2011 19:22:58 +1000 Subject: [PATCH] + integration test for database reindexing in a running server --- server/lib/picky/sources/db.rb | 1 - server/test_project/spec/integration_spec.rb | 27 ++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/server/lib/picky/sources/db.rb b/server/lib/picky/sources/db.rb index ba083945..448eb639 100644 --- a/server/lib/picky/sources/db.rb +++ b/server/lib/picky/sources/db.rb @@ -134,7 +134,6 @@ def harvest category, &block # Gets the data from the backend. # def get_data category, offset, &block # :nodoc: - select_statement = harvest_statement_with_offset category, offset # TODO Rewrite ASAP. diff --git a/server/test_project/spec/integration_spec.rb b/server/test_project/spec/integration_spec.rb index 8c79e675..09d3175a 100644 --- a/server/test_project/spec/integration_spec.rb +++ b/server/test_project/spec/integration_spec.rb @@ -236,8 +236,31 @@ it { csv.search("HISTORY FERGUS").ids.should == [] } it { csv.search("history AND OR fergus").ids.should == [4, 4] } - # Specific indexing. + # Database index reloading. # - + it 'can handle changing data with a Memory backend with a DB source' do + books.search('1977').ids.should == [86, 394] + + # Some webapp adds a book. + # + BookSearch::Book.establish_connection YAML.load(File.open('app/db.yml')) + added_book = BookSearch::Book.create! title: "Some Title", + author: "Tester Mc Testy", + isbn: "1231231231231", + year: 1977 + expected_id = added_book.id + + # TODO Remove this line and include take_snapshot cleanly in indexing. + # + Indexes[:books].take_snapshot # Works if this one is not commented. + Indexes[:books].index + Indexes[:books].reload + + # We can destroy the book now as it has been indexed. + # + added_book.destroy + + books.search('1977').ids.should == [86, 394, expected_id] + end end \ No newline at end of file