aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/outgoing_mailer_spec.rb31
-rw-r--r--spec/models/raw_email_spec.rb4
2 files changed, 33 insertions, 2 deletions
diff --git a/spec/models/outgoing_mailer_spec.rb b/spec/models/outgoing_mailer_spec.rb
index 3073c5ffd..83da7a553 100644
--- a/spec/models/outgoing_mailer_spec.rb
+++ b/spec/models/outgoing_mailer_spec.rb
@@ -6,6 +6,23 @@ describe OutgoingMailer, " when working out follow up addresses" do
# mocks. Put parts of the tests in spec/lib/tmail_extensions.rb
fixtures :info_requests, :incoming_messages, :raw_emails, :public_bodies, :public_body_translations
+ before do
+ # XXX this is a hack around the fact that our raw_email model
+ # is in transition to something that doesn't actually live in
+ # the database at all. The raw_email fixture saves to the
+ # model, the model then needs to be told to save itself on the
+ # filesystem.
+ raw_email = raw_emails(:useless_raw_email)
+ raw_email.data=raw_email.dbdata
+ end
+
+ after do
+ # And this is a hack around the fact that Rails fixtures don't
+ # have teardowns happen on them; we need to ensure no emails
+ # are left lying around
+ raw_emails(:useless_raw_email).destroy_file_representation!
+ end
+
it "should parse them right" do
ir = info_requests(:fancy_dog_request)
im = ir.incoming_messages[0]
@@ -67,8 +84,17 @@ describe OutgoingMailer, " when working out follow up addresses" do
end
describe OutgoingMailer, "when working out follow up subjects" do
- fixtures :info_requests, :incoming_messages, :outgoing_messages
-
+ fixtures :info_requests, :incoming_messages, :outgoing_messages, :raw_emails
+
+ before do
+ raw_email = raw_emails(:useless_raw_email)
+ raw_email.data=raw_email.dbdata
+ end
+
+ after do
+ raw_emails(:useless_raw_email).destroy_file_representation!
+ end
+
it "should prefix the title with 'Freedom of Information request -' for initial requests" do
ir = info_requests(:fancy_dog_request)
im = ir.incoming_messages[0]
@@ -105,6 +131,7 @@ describe OutgoingMailer, "when working out follow up subjects" do
it "should not add Re: prefix if there already is a lower case re: prefix" do
ir = info_requests(:fancy_dog_request)
im = ir.incoming_messages[0]
+ puts im.raw_email.data
om = outgoing_messages(:useless_outgoing_message)
om.incoming_message_followup = im
diff --git a/spec/models/raw_email_spec.rb b/spec/models/raw_email_spec.rb
index 6f3a8acd6..ff2830a62 100644
--- a/spec/models/raw_email_spec.rb
+++ b/spec/models/raw_email_spec.rb
@@ -3,6 +3,10 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe User, "manipulating a raw email" do
before do
@raw_email = RawEmail.new
+ incoming_message = mock_model(IncomingMessage)
+ info_request = mock_model(InfoRequest)
+ incoming_message.stub!(:info_request).and_return(info_request)
+ @raw_email.stub!(:incoming_message).and_return(incoming_message)
end
it 'putting data in comes back out' do