aboutsummaryrefslogtreecommitdiffstats
path: root/spec/support/xapian_index.rb
diff options
context:
space:
mode:
authorHenare Degan <henare.degan@gmail.com>2012-12-18 18:31:33 +1100
committerHenare Degan <henare.degan@gmail.com>2013-01-18 01:53:57 +1100
commit50dd3ad01371e73912f8c2bf3a9fad70c8aa94fb (patch)
treeede03a9999fcf9822f10a68c218b7c22f422a383 /spec/support/xapian_index.rb
parentc17ce2e29e15c44b212d975ad1868453a8391acf (diff)
Add some more xapian methods for models/xapian_spec.rb
Diffstat (limited to 'spec/support/xapian_index.rb')
-rw-r--r--spec/support/xapian_index.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/support/xapian_index.rb b/spec/support/xapian_index.rb
index 21f6192ef..344c28ebb 100644
--- a/spec/support/xapian_index.rb
+++ b/spec/support/xapian_index.rb
@@ -19,3 +19,24 @@ end
def update_xapian_index
ActsAsXapian.update_index(flush_to_disk=false, verbose=false)
end
+
+# Copy the xapian index created in create_fixtures_xapian_index to a temporary
+# copy at the same level and point xapian at the copy
+def get_fixtures_xapian_index()
+ # Create a base index for the fixtures if not already created
+ $existing_xapian_db ||= create_fixtures_xapian_index
+ # Store whatever the xapian db path is originally
+ $original_xapian_path ||= ActsAsXapian.db_path
+ path_array = $original_xapian_path.split(File::Separator)
+ path_array.pop
+ temp_path = File.join(path_array, 'test.temp')
+ FileUtils.remove_entry_secure(temp_path, force=true)
+ FileUtils.cp_r($original_xapian_path, temp_path)
+ ActsAsXapian.db_path = temp_path
+end
+
+# Create a clean xapian index based on the fixture files and the raw_email data.
+def create_fixtures_xapian_index
+ load_raw_emails_data
+ rebuild_xapian_index
+end