Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add integration spec for offline indexing
- Loading branch information
1 parent
c2a5a23
commit 12258a5
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require File.expand_path("../../spec_helper", __FILE__) | ||
|
||
describe "Building an index offline" do | ||
before do | ||
$db.drop_table :awesome_things if $db.table_exists?(:awesome_things) | ||
|
||
if $db.table_exists?(:index_awesome_things_on_name) | ||
$db.drop_table :awesome_things_on_name | ||
end | ||
|
||
@klass = Class.new do | ||
def self.name; "AwesomeThing"; end | ||
def self.table_name; "awesome_things"; end | ||
|
||
include Friendly::Document | ||
|
||
attribute :name, String | ||
end | ||
@klass.create_tables! | ||
|
||
@jameses = [@klass.create(:name => "James"), @klass.create(:name => "James")] | ||
|
||
@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 | ||
end | ||
end |