aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Landauer <matthew@openaustralia.org>2013-01-04 14:46:17 +1100
committerMatthew Landauer <matthew@openaustralia.org>2013-01-04 14:46:17 +1100
commitc9c599daacc54dcba508fa5868e3aef928b5670d (patch)
treec950775ac06fdc31ba404969e005d8a22b2a5d15
parent2ba57e8ce538785359d345c90ec8bfb4b7c5764b (diff)
Moved two needed helper functions from spec/spec_helper.rb.rails2
-rw-r--r--spec/spec_helper.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 3c170ed16..0e0eebb6e 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -53,3 +53,26 @@ RSpec.configure do |config|
# --seed 1234
#config.order = "random"
end
+
+# XXX No idea what namespace/class/module to put this in
+# 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
+
+# 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
+