aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/fixtures/incoming-request-plain.email18
-rw-r--r--spec/models/request_mailer_spec.rb14
-rw-r--r--spec/spec_helper.rb10
3 files changed, 41 insertions, 1 deletions
diff --git a/spec/fixtures/incoming-request-plain.email b/spec/fixtures/incoming-request-plain.email
new file mode 100644
index 000000000..9072b32cc
--- /dev/null
+++ b/spec/fixtures/incoming-request-plain.email
@@ -0,0 +1,18 @@
+From: Bob Smith <bob@localhost>
+To: FOI Person <EMAIL_TO>
+Bcc:
+Subject: Re: Freedom of Information Request - Why aren't you leaving the house?
+Reply-To:
+In-Reply-To: <471f1eae5d1cb_7347..fdbe67386163@cat.tmail>
+
+No way! That's so totally a rubbish question. No way am I answering that.
+
+The Geraldine Quango
+
+On Wed, Oct 24, 2007 at 11:30:06AM +0100, francis@flourish.org wrote:
+> Please let me know why Francis isn't getting ready to leave the house
+> to go to the UN talk.
+>
+> Love,
+>
+> Francis
diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb
index 712ba2484..030395a2d 100644
--- a/spec/models/request_mailer_spec.rb
+++ b/spec/models/request_mailer_spec.rb
@@ -1,8 +1,20 @@
require File.dirname(__FILE__) + '/../spec_helper'
-describe RequestMailer, " when blah" do
+describe RequestMailer, " when receiving incoming mail" do
+ fixtures :info_requests
+
before do
+
end
+
+ it "should append it to the appropriate request" do
+ ir = info_requests(:fancy_dog_request)
+ receive_incoming_mail('incoming-request-plain.email', ir.incoming_email)
+ ir.incoming_messages.size.should == 1
+ end
+
+ it "should XXX when the email is not to any information request"
end
+
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 2d01d442e..b1427f71d 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -22,3 +22,13 @@ Spec::Runner.configure do |config|
# for all of your examples, even those that don't use them.
end
+# XXX No idea what namespace/class/module to put this in
+def receive_incoming_mail(email_name, email_to)
+ email_name = File.join(Spec::Runner.configuration.fixture_path, email_name)
+ content = File.read(email_name)
+ content.gsub!('EMAIL_TO', email_to)
+ RequestMailer.receive(content)
+end
+
+
+