aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/request_controller_spec.rb4
-rw-r--r--spec/fixtures/incoming_messages.yml25
-rw-r--r--spec/models/incoming_message_spec.rb10
-rw-r--r--spec/models/request_mailer_spec.rb6
4 files changed, 36 insertions, 9 deletions
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index bca0a2a57..5758e2b2a 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -49,7 +49,7 @@ end
describe RequestController, "when showing one request" do
integrate_views
- fixtures :info_requests, :public_bodies, :users # all needed as integrating views
+ fixtures :info_requests, :public_bodies, :users, :incoming_messages # all needed as integrating views
it "should be successful" do
get :show, :id => 101
@@ -70,7 +70,7 @@ describe RequestController, "when showing one request" do
ir = info_requests(:fancy_dog_request)
receive_incoming_mail('incoming-request-plain.email', ir.incoming_email)
get :show, :id => 101
- assigns[:correspondences].size.should == 1
+ assigns[:correspondences].size.should == 2
end
end
diff --git a/spec/fixtures/incoming_messages.yml b/spec/fixtures/incoming_messages.yml
index cb3dfa5e6..2e3c74f69 100644
--- a/spec/fixtures/incoming_messages.yml
+++ b/spec/fixtures/incoming_messages.yml
@@ -1,4 +1,23 @@
-new_request_message:
+useless_incoming_message:
id: 1
- info_request_id: 1
- raw_data: xxxx \ No newline at end of file
+ info_request_id: 101
+ updated_at: 2007-11-13 18:09:20.042061
+ raw_data: |
+ From: Francis Irving <frabcus@fastmail.fm>
+ To: FOI Person <foiperson@localhost>
+ Date: Tue, 13 Nov 2007 11:39:55 +0000
+ NoCc: foi+request-1-4b571715@cat
+ Bcc:
+ Subject: Re: Freedom of Information Request - Why do you have such a fancy dog?
+ Reply-To:
+ In-Reply-To: <471f1eae5d1cb_7347..fdbe67386163@cat.tmail>
+
+ No way! I'm not going to tell you that in a month of Thursdays.
+
+ The Geraldine Quango
+
+ On Wed, Oct 24, 2007 at 11:30:06AM +0100, Bob Smith wrote:
+ > Why do you have such a fancy dog?
+
+ created_at: 2007-11-13 18:09:20.042061
+
diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb
index 25f2fce5f..55c042141 100644
--- a/spec/models/incoming_message_spec.rb
+++ b/spec/models/incoming_message_spec.rb
@@ -1,8 +1,16 @@
require File.dirname(__FILE__) + '/../spec_helper'
-describe IncomingMessage, " when blah" do
+describe IncomingMessage, " when dealing with incoming mail" do
+ fixtures :incoming_messages
+
before do
+ @im = incoming_messages(:useless_incoming_message)
+ end
+
+ it "should return the mail Date header date for sent at" do
+ @im.sent_at.should == @im.mail.date
end
+
end
diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb
index 8bac9e5da..67a9536af 100644
--- a/spec/models/request_mailer_spec.rb
+++ b/spec/models/request_mailer_spec.rb
@@ -1,7 +1,7 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe RequestMailer, " when receiving incoming mail" do
- fixtures :info_requests
+ fixtures :info_requests, :incoming_messages
before do
@@ -10,13 +10,13 @@ describe RequestMailer, " when receiving incoming mail" do
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
+ ir.incoming_messages.size.should == 2
end
it "should bounce email to admin when the email is not to any information request" do
ir = info_requests(:fancy_dog_request)
receive_incoming_mail('incoming-request-plain.email', 'dummy@localhost')
- ir.incoming_messages.size.should == 0
+ ir.incoming_messages.size.should == 1
deliveries = ActionMailer::Base.deliveries
deliveries.size.should == 1