diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/spec_helper.rb.rails2 | 26 | ||||
-rw-r--r-- | spec/support/email_helpers.rb (renamed from spec/support/load_email_fixtures.rb) | 4 | ||||
-rw-r--r-- | spec/support/xapian_index.rb | 21 |
3 files changed, 25 insertions, 26 deletions
diff --git a/spec/spec_helper.rb.rails2 b/spec/spec_helper.rb.rails2 index a904f7bad..3be11c0c7 100644 --- a/spec/spec_helper.rb.rails2 +++ b/spec/spec_helper.rb.rails2 @@ -95,38 +95,12 @@ Spec::Runner.configure do |config| end # XXX No idea what namespace/class/module to put this in -def parse_all_incoming_messages - IncomingMessage.find(:all).each{ |x| x.parse_raw_email! } -end - -# 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 - # 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 -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() diff --git a/spec/support/load_email_fixtures.rb b/spec/support/email_helpers.rb index d0575f029..7e98c39f6 100644 --- a/spec/support/load_email_fixtures.rb +++ b/spec/support/email_helpers.rb @@ -17,3 +17,7 @@ end def get_fixture_mail(filename) MailHandler.mail_from_raw_email(load_file_fixture(filename)) end + +def parse_all_incoming_messages + IncomingMessage.find(:all).each{ |x| x.parse_raw_email! } +end 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 |