aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/fixtures/incoming-request-plain.email2
-rw-r--r--spec/models/request_mailer_spec.rb23
2 files changed, 23 insertions, 2 deletions
diff --git a/spec/fixtures/incoming-request-plain.email b/spec/fixtures/incoming-request-plain.email
index ce1c7caa7..4ee258d2a 100644
--- a/spec/fixtures/incoming-request-plain.email
+++ b/spec/fixtures/incoming-request-plain.email
@@ -1,4 +1,4 @@
-From: Bob Smith <bob@localhost>
+From: geraldinequango@localhost
To: FOI Person <EMAIL_TO>
Bcc:
Subject: Re: Freedom of Information Request - Why aren't you leaving the house?
diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb
index 8c7eaefe2..98c27cca9 100644
--- a/spec/models/request_mailer_spec.rb
+++ b/spec/models/request_mailer_spec.rb
@@ -21,11 +21,32 @@ describe RequestMailer, " when receiving incoming mail" do
ir.incoming_messages.size.should == 1
deliveries = ActionMailer::Base.deliveries
- deliveries.size.should == 1
+ deliveries.size.should == 1
mail = deliveries[0]
mail.to.should == [ MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost') ]
+ deliveries.clear
end
+ it "should return incoming mail to sender when a request is stopped for spam" do
+ # mark request as anti-spam
+ ir = info_requests(:fancy_dog_request)
+ ir.stop_new_responses = true
+ ir.save!
+
+ # test what happens if something arrives
+ ir.incoming_messages.size.should == 1 # in the fixture
+ receive_incoming_mail('incoming-request-plain.email', ir.incoming_email)
+ ir.incoming_messages.size.should == 1 # nothing should arrive
+
+ # should be a message back to sender
+ deliveries = ActionMailer::Base.deliveries
+ deliveries.size.should == 1
+ mail = deliveries[0]
+ mail.to.should == [ 'geraldinequango@localhost' ]
+ deliveries.clear
+ end
+
+
it "should not mutilate long URLs when trying to word wrap them" do
long_url = 'http://www.this.is.quite.a.long.url.flourish.org/there.is.no.way.it.is.short.whatsoever'
body = "This is a message with quite a long URL in it. It also has a paragraph, being this one that has quite a lot of text in it to. Enough to test the wrapping of itself.