diff options
author | Louise Crow <louise.crow@gmail.com> | 2012-12-11 14:07:54 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2012-12-11 14:23:16 +0000 |
commit | e898190fe61a4369ee83e94a24327ff437435b07 (patch) | |
tree | 42f1fe6ee90dfe0bf3f9c7d36a80490b63056978 /spec/models/incoming_message_spec.rb | |
parent | 7cfa3956fd373db35948ef33cde652b30229f9ad (diff) |
Wrap specs on the extraction of RFC-822 headers in code that sets the ENV timezone. TMail renders headers using localtime, which is not ideal, but we're migrating away from it anyway, so I'm not sure it's worth delving into the internals of TMail to fix it.
Diffstat (limited to 'spec/models/incoming_message_spec.rb')
-rw-r--r-- | spec/models/incoming_message_spec.rb | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb index 70b323e9f..6fc0ff3cc 100644 --- a/spec/models/incoming_message_spec.rb +++ b/spec/models/incoming_message_spec.rb @@ -429,21 +429,25 @@ end describe IncomingMessage, "when messages are attached to messages" do it 'should expand an RFC822 attachment' do - mail_body = load_file_fixture('rfc822-attachment.email') - mail = MailHandler.mail_from_raw_email(mail_body) - - im = incoming_messages(:useless_incoming_message) - im.stub!(:mail).and_return(mail) - - attachments = im.get_attachments_for_display - attachments.size.should == 1 - attachment = attachments.first - - attachment.content_type.should == 'text/plain' - attachment.filename.should == "Freedom of Information request.txt" - attachment.charset.should == "utf-8" - attachment.within_rfc822_subject.should == "Freedom of Information request" - attachment.hexdigest.should == 'f10fe56e4f2287685a58b71329f09639' + # Note that this spec will only pass using Tmail in the timezone set as datetime headers + # are rendered out in the local time - using the Mail gem this is not necessary + with_env_tz('London') do + mail_body = load_file_fixture('rfc822-attachment.email') + mail = MailHandler.mail_from_raw_email(mail_body) + + im = incoming_messages(:useless_incoming_message) + im.stub!(:mail).and_return(mail) + + attachments = im.get_attachments_for_display + attachments.size.should == 1 + attachment = attachments.first + + attachment.content_type.should == 'text/plain' + attachment.filename.should == "Freedom of Information request.txt" + attachment.charset.should == "utf-8" + attachment.within_rfc822_subject.should == "Freedom of Information request" + attachment.hexdigest.should == 'f10fe56e4f2287685a58b71329f09639' + end end it "should flatten all the attachments out" do @@ -463,15 +467,19 @@ describe IncomingMessage, "when messages are attached to messages" do end it 'should add headers to attached plain text message bodies' do - mail_body = load_file_fixture('incoming-request-attachment-headers.email') - mail = MailHandler.mail_from_raw_email(mail_body) - - im = incoming_messages(:useless_incoming_message) - im.stub!(:mail).and_return(mail) - - attachments = im.get_attachments_for_display - attachments.size.should == 2 - attachments[0].body.should match('Date: Fri, 23 May 2008') + # Note that this spec will only pass using Tmail in the timezone set as datetime headers + # are rendered out in the local time - using the Mail gem this is not necessary + with_env_tz('London') do + mail_body = load_file_fixture('incoming-request-attachment-headers.email') + mail = MailHandler.mail_from_raw_email(mail_body) + + im = incoming_messages(:useless_incoming_message) + im.stub!(:mail).and_return(mail) + + attachments = im.get_attachments_for_display + attachments.size.should == 2 + attachments[0].body.should match('Date: Fri, 23 May 2008') + end end end |