diff options
author | Henare Degan <henare.degan@gmail.com> | 2012-12-12 16:05:47 +1100 |
---|---|---|
committer | Henare Degan <henare.degan@gmail.com> | 2012-12-12 16:05:47 +1100 |
commit | b9d7b5e15db08113161aea660ad76ee678c704c1 (patch) | |
tree | 740c93044636b4faec7dec2e8dc1494442b510c6 /spec/support/xapian_index.rb | |
parent | 4b6fb7bb4bb01fdc3fcc4ae9d80543c1789485b6 (diff) |
Add more spec helper methods and update acts_as_xapian to make info_request model specs pass
Diffstat (limited to 'spec/support/xapian_index.rb')
-rw-r--r-- | spec/support/xapian_index.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/support/xapian_index.rb b/spec/support/xapian_index.rb new file mode 100644 index 000000000..21f6192ef --- /dev/null +++ b/spec/support/xapian_index.rb @@ -0,0 +1,21 @@ +# Rebuild the current xapian index +def rebuild_xapian_index(terms = true, values = true, texts = true, dropfirst = true) + if dropfirst + begin + ActsAsXapian.readable_init + FileUtils.rm_r(ActsAsXapian.db_path) + rescue RuntimeError + end + ActsAsXapian.writable_init + ActsAsXapian.writable_db.close + end + parse_all_incoming_messages + # safe_rebuild=true, which involves forking to avoid memory leaks, doesn't work well with rspec. + # unsafe is significantly faster, and we can afford possible memory leaks while testing. + models = [PublicBody, User, InfoRequestEvent] + ActsAsXapian.rebuild_index(models, verbose=false, terms, values, texts, safe_rebuild=false) +end + +def update_xapian_index + ActsAsXapian.update_index(flush_to_disk=false, verbose=false) +end |