aboutsummaryrefslogtreecommitdiffstats
path: root/spec/mailers
diff options
context:
space:
mode:
Diffstat (limited to 'spec/mailers')
-rw-r--r--spec/mailers/outgoing_mailer_spec.rb12
-rw-r--r--spec/mailers/request_mailer_spec.rb32
2 files changed, 36 insertions, 8 deletions
diff --git a/spec/mailers/outgoing_mailer_spec.rb b/spec/mailers/outgoing_mailer_spec.rb
index a11d56dd3..3df5018fe 100644
--- a/spec/mailers/outgoing_mailer_spec.rb
+++ b/spec/mailers/outgoing_mailer_spec.rb
@@ -75,14 +75,14 @@ describe OutgoingMailer, "when working out follow up subjects" do
ir = info_requests(:fancy_dog_request)
im = ir.incoming_messages[0]
- ir.email_subject_request.should == "Freedom of Information request - Why do you have & such a fancy dog?"
+ ir.email_subject_request(:html => false).should == "Freedom of Information request - Why do you have & such a fancy dog?"
end
it "should use 'Re:' and inital request subject for followups which aren't replies to particular messages" do
ir = info_requests(:fancy_dog_request)
om = outgoing_messages(:useless_outgoing_message)
- OutgoingMailer.subject_for_followup(ir, om).should == "Re: Freedom of Information request - Why do you have & such a fancy dog?"
+ OutgoingMailer.subject_for_followup(ir, om, :html => false).should == "Re: Freedom of Information request - Why do you have & such a fancy dog?"
end
it "should prefix with Re: the subject of the message being replied to" do
@@ -91,7 +91,7 @@ describe OutgoingMailer, "when working out follow up subjects" do
om = outgoing_messages(:useless_outgoing_message)
om.incoming_message_followup = im
- OutgoingMailer.subject_for_followup(ir, om).should == "Re: Geraldine FOI Code AZXB421"
+ OutgoingMailer.subject_for_followup(ir, om, :html => false).should == "Re: Geraldine FOI Code AZXB421"
end
it "should not add Re: prefix if there already is such a prefix" do
@@ -101,7 +101,7 @@ describe OutgoingMailer, "when working out follow up subjects" do
om.incoming_message_followup = im
im.raw_email.data = im.raw_email.data.sub("Subject: Geraldine FOI Code AZXB421", "Subject: Re: Geraldine FOI Code AZXB421")
- OutgoingMailer.subject_for_followup(ir, om).should == "Re: Geraldine FOI Code AZXB421"
+ OutgoingMailer.subject_for_followup(ir, om, :html => false).should == "Re: Geraldine FOI Code AZXB421"
end
it "should not add Re: prefix if there already is a lower case re: prefix" do
@@ -113,7 +113,7 @@ describe OutgoingMailer, "when working out follow up subjects" do
im.raw_email.data = im.raw_email.data.sub("Subject: Geraldine FOI Code AZXB421", "Subject: re: Geraldine FOI Code AZXB421")
im.parse_raw_email! true
- OutgoingMailer.subject_for_followup(ir, om).should == "re: Geraldine FOI Code AZXB421"
+ OutgoingMailer.subject_for_followup(ir, om, :html => false).should == "re: Geraldine FOI Code AZXB421"
end
it "should use 'Re:' and initial request subject when replying to failed delivery notifications" do
@@ -126,7 +126,7 @@ describe OutgoingMailer, "when working out follow up subjects" do
im.raw_email.data = im.raw_email.data.sub("Subject: Geraldine FOI Code AZXB421", "Subject: Delivery Failed")
im.parse_raw_email! true
- OutgoingMailer.subject_for_followup(ir, om).should == "Re: Freedom of Information request - Why do you have & such a fancy dog?"
+ OutgoingMailer.subject_for_followup(ir, om, :html => false).should == "Re: Freedom of Information request - Why do you have & such a fancy dog?"
end
end
diff --git a/spec/mailers/request_mailer_spec.rb b/spec/mailers/request_mailer_spec.rb
index 2c5d6e6a9..9e98dbc00 100644
--- a/spec/mailers/request_mailer_spec.rb
+++ b/spec/mailers/request_mailer_spec.rb
@@ -38,6 +38,35 @@ describe RequestMailer, " when receiving incoming mail" do
deliveries.clear
end
+ it "should parse attachments from mails sent with apple mail" do
+ ir = info_requests(:fancy_dog_request)
+ ir.incoming_messages.size.should == 1
+ InfoRequest.holding_pen_request.incoming_messages.size.should == 0
+ receive_incoming_mail('apple-mail-with-attachments.email', 'dummy@localhost')
+ ir.incoming_messages.size.should == 1
+ InfoRequest.holding_pen_request.incoming_messages.size.should == 1
+ last_event = InfoRequest.holding_pen_request.incoming_messages[0].info_request.info_request_events.last
+ last_event.params[:rejected_reason].should == "Could not identify the request from the email address"
+
+ im = IncomingMessage.last
+ # Check that the attachments haven't been somehow loaded from a
+ # previous test run
+ im.foi_attachments.size.should == 0
+
+ # Trace where attachments first get loaded:
+ # TODO: Ideally this should be 3, but some html parts from Apple Mail
+ # are being treated like attachments
+ im.extract_attachments!
+ im.foi_attachments.size.should == 6
+
+ # Clean up
+ deliveries = ActionMailer::Base.deliveries
+ deliveries.size.should == 1
+ mail = deliveries[0]
+ mail.to.should == [ AlaveteliConfiguration::contact_email ]
+ deliveries.clear
+ end
+
it "should store mail in holding pen and send to admin when the from email is empty and only authorites can reply" do
ir = info_requests(:fancy_dog_request)
ir.allow_new_responses_from = 'authority_only'
@@ -398,8 +427,7 @@ describe RequestMailer, 'requires_admin' do
it 'body should contain the full admin URL' do
mail = RequestMailer.requires_admin(@info_request).deliver
-
- mail.body.should include('http://test.host/en/admin/request/show/123')
+ mail.body.should include('http://test.host/en/admin/requests/123')
end
it "body should contain the message from the user" do