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/email_helpers.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/email_helpers.rb')
-rw-r--r-- | spec/support/email_helpers.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/support/email_helpers.rb b/spec/support/email_helpers.rb new file mode 100644 index 000000000..7e98c39f6 --- /dev/null +++ b/spec/support/email_helpers.rb @@ -0,0 +1,23 @@ +def load_raw_emails_data + raw_emails_yml = File.join(RSpec.configuration.fixture_path, "raw_emails.yml") + for raw_email_id in YAML::load_file(raw_emails_yml).map{|k,v| v["id"]} do + raw_email = RawEmail.find(raw_email_id) + raw_email.data = load_file_fixture("raw_emails/%d.email" % [raw_email_id]) + end +end + +def receive_incoming_mail(email_name, email_to, email_from = 'geraldinequango@localhost') + email_name = file_fixture_name(email_name) + content = File.read(email_name) + content.gsub!('EMAIL_TO', email_to) + content.gsub!('EMAIL_FROM', email_from) + RequestMailer.receive(content) +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 |