aboutsummaryrefslogtreecommitdiffstats
path: root/spec/support/load_email_fixtures.rb
diff options
context:
space:
mode:
authorHenare Degan <henare.degan@gmail.com>2012-12-12 14:21:26 +1100
committerHenare Degan <henare.degan@gmail.com>2012-12-12 15:39:29 +1100
commit1fc3bea6cb0a2fc5e26c171dd7f83dc155c962f9 (patch)
tree18f1084e7d8c6cf39d506bd390c53e230e9b876c /spec/support/load_email_fixtures.rb
parent2f18efd75d79770941faa3c104dd6ca7a4e898b2 (diff)
Allow the IncomingMessage model specs to run
Diffstat (limited to 'spec/support/load_email_fixtures.rb')
-rw-r--r--spec/support/load_email_fixtures.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/support/load_email_fixtures.rb b/spec/support/load_email_fixtures.rb
new file mode 100644
index 000000000..d0575f029
--- /dev/null
+++ b/spec/support/load_email_fixtures.rb
@@ -0,0 +1,19 @@
+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