Skip to content

Commit

Permalink
+ integration test for database reindexing in a running server
Browse files Browse the repository at this point in the history
  • Loading branch information
floere committed Jul 5, 2011
1 parent e687c34 commit bd29ca6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
1 change: 0 additions & 1 deletion server/lib/picky/sources/db.rb
Expand Up @@ -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.
Expand Down
27 changes: 25 additions & 2 deletions server/test_project/spec/integration_spec.rb
Expand Up @@ -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

0 comments on commit bd29ca6

Please sign in to comment.