diff options
author | francis <francis> | 2009-10-04 21:54:09 +0000 |
---|---|---|
committer | francis <francis> | 2009-10-04 21:54:09 +0000 |
commit | f3de94d4ad38cf753e66eb296d5489fcf60b5e57 (patch) | |
tree | 3cf853a7eeae63600125a97cd866154ae3728a7a | |
parent | 1890f41864adf2b6945a66636fbc2772b9f018cd (diff) |
Forgot to add this.
-rw-r--r-- | spec/models/outgoing_mailer_spec.rb | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/spec/models/outgoing_mailer_spec.rb b/spec/models/outgoing_mailer_spec.rb new file mode 100644 index 000000000..8317d12d8 --- /dev/null +++ b/spec/models/outgoing_mailer_spec.rb @@ -0,0 +1,69 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe OutgoingMailer, " when working out follow up addresses" do + # This is done with fixtures as the code is a bit tangled with the way it + # calls TMail. XXX untangle it and make these tests spread out and using + # mocks. Put parts of the tests in spec/lib/tmail_extensions.rb + fixtures :info_requests, :incoming_messages, :raw_emails, :public_bodies + + it "should parse them right" do + ir = info_requests(:fancy_dog_request) + im = ir.incoming_messages[0] + + # check the basic entry in the fixture is fine + OutgoingMailer.name_and_email_for_followup(ir, im).should == "FOI Person <foiperson@localhost>" + OutgoingMailer.name_for_followup(ir, im).should == "FOI Person" + OutgoingMailer.email_for_followup(ir, im).should == "foiperson@localhost" + end + + it "should work when there is only an email address" do + ir = info_requests(:fancy_dog_request) + im = ir.incoming_messages[0] + + im.raw_email.data.sub!("\"FOI Person\" <foiperson@localhost>", "foiperson@localhost") + + # check the basic entry in the fixture is fine + OutgoingMailer.name_and_email_for_followup(ir, im).should == "foiperson@localhost" + OutgoingMailer.name_for_followup(ir, im).should == "The Geraldine Quango" + OutgoingMailer.email_for_followup(ir, im).should == "foiperson@localhost" + end + + it "should quote funny characters" do + ir = info_requests(:fancy_dog_request) + im = ir.incoming_messages[0] + + im.raw_email.data.sub!("FOI Person", "FOI [ Person") + + # check the basic entry in the fixture is fine + OutgoingMailer.name_and_email_for_followup(ir, im).should == "\"FOI [ Person\" <foiperson@localhost>" + OutgoingMailer.name_for_followup(ir, im).should == "FOI [ Person" + OutgoingMailer.email_for_followup(ir, im).should == "foiperson@localhost" + end + + it "should quote quotes" do + ir = info_requests(:fancy_dog_request) + im = ir.incoming_messages[0] + + im.raw_email.data.sub!("FOI Person", "FOI \\\" Person") + + # check the basic entry in the fixture is fine + OutgoingMailer.name_and_email_for_followup(ir, im).should == "\"FOI \\\" Person\" <foiperson@localhost>" + OutgoingMailer.name_for_followup(ir, im).should == "FOI \" Person" + OutgoingMailer.email_for_followup(ir, im).should == "foiperson@localhost" + end + + it "should quote @ signs" do + ir = info_requests(:fancy_dog_request) + im = ir.incoming_messages[0] + + im.raw_email.data.sub!("FOI Person", "FOI @ Person") + + # check the basic entry in the fixture is fine + OutgoingMailer.name_and_email_for_followup(ir, im).should == "\"FOI @ Person\" <foiperson@localhost>" + OutgoingMailer.name_for_followup(ir, im).should == "FOI @ Person" + OutgoingMailer.email_for_followup(ir, im).should == "foiperson@localhost" + end + +end + + |