diff options
author | Louise Crow <louise.crow@gmail.com> | 2012-11-12 15:06:46 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2012-11-12 15:06:46 +0000 |
commit | a1ca0f9123a3aea843ba35508a97d5a4fd5cb0db (patch) | |
tree | b9d3c1390f6b9c8b201e47507f26829b239f2773 /spec/models/incoming_message_spec.rb | |
parent | 8271b2c664f04d1b68a8b4d4fdb801f5c6b00b8c (diff) | |
parent | c96b27c301023a6a1f50c12f0c387205b0255836 (diff) |
Merge remote-tracking branch 'origin/release/0.6.8'0.6.8
Conflicts:
locale/cs/app.po
locale/sl/app.po
locale/sq/app.po
locale/tr/app.po
locale/uk/app.po
Diffstat (limited to 'spec/models/incoming_message_spec.rb')
-rw-r--r-- | spec/models/incoming_message_spec.rb | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb index cf84b4595..b038c43d9 100644 --- a/spec/models/incoming_message_spec.rb +++ b/spec/models/incoming_message_spec.rb @@ -12,6 +12,14 @@ describe IncomingMessage, " when dealing with incoming mail" do ActionMailer::Base.deliveries.clear end + it 'should correctly parse multipart mails with a linebreak in the boundary marker' do + ir = info_requests(:fancy_dog_request) + receive_incoming_mail('space-boundary.email', ir.incoming_email) + message = ir.incoming_messages[1] + message.mail.parts.size.should == 2 + message.mail.multipart?.should == true + end + it "should return the mail Date header date for sent at" do @im.parse_raw_email!(true) @im.reload @@ -60,7 +68,6 @@ describe IncomingMessage, " when dealing with incoming mail" do is not good utf-8' do ir = info_requests(:fancy_dog_request) receive_incoming_mail('no-part-charset-bad-utf8.email', ir.incoming_email) - puts ir.incoming_messages.inspect message = ir.incoming_messages[1] message.parse_raw_email! message.get_main_body_text_internal.should include("The above text was badly encoded") @@ -125,21 +132,45 @@ end describe IncomingMessage, " folding quoted parts of emails" do - it "cope with [ in user names properly" do - @user = mock_model(User) - @user.stub!(:name).and_return("Sir [ Bobble") - @info_request = mock_model(InfoRequest) - @info_request.stub!(:user).and_return(@user) - @info_request.stub!(:user_name).and_return(@user.name) + it 'should fold an example lotus notes quoted part converted from HTML correctly' do + ir = info_requests(:fancy_dog_request) + receive_incoming_mail('lotus-notes-quoting.email', ir.incoming_email) + message = ir.incoming_messages[1] + message.get_main_body_text_folded.should match(/FOLDED_QUOTED_SECTION/) + end + it 'should fold a plain text lotus notes quoted part correctly' do + text = "FOI Team\n\n\nInfo Requester <xxx@whatdotheyknow.com>=20\nSent by: Info Requester <request-bounce-xxxxx@whatdotheyknow.com>\n06/03/08 10:00\nPlease respond to\nInfo Requester <request-xxxx@whatdotheyknow.com>" @incoming_message = IncomingMessage.new() - @incoming_message.info_request = @info_request + @incoming_message.stub_chain(:info_request, :user_name).and_return("Info Requester") + @incoming_message.remove_lotus_quoting(text).should match(/FOLDED_QUOTED_SECTION/) + end + it "cope with [ in user names properly" do + @incoming_message = IncomingMessage.new() + @incoming_message.stub_chain(:info_request, :user_name).and_return("Sir [ Bobble") # this gives a warning if [ is in the name text = @incoming_message.remove_lotus_quoting("Sir [ Bobble \nSent by: \n") text.should == "\n\nFOLDED_QUOTED_SECTION" end + it 'should fold an example of another kind of forward quoting' do + ir = info_requests(:fancy_dog_request) + receive_incoming_mail('forward-quoting-example.email', ir.incoming_email) + message = ir.incoming_messages[1] + message.get_main_body_text_folded.should match(/FOLDED_QUOTED_SECTION/) + end + + it 'should fold a further example of forward quoting' do + ir = info_requests(:fancy_dog_request) + receive_incoming_mail('forward-quoting-example-2.email', ir.incoming_email) + message = ir.incoming_messages[1] + body_text = message.get_main_body_text_folded + body_text.should match(/FOLDED_QUOTED_SECTION/) + # check that the quoted section incorporates both quoted messages + body_text.should_not match('Subject: RE: Freedom of Information request') + end + end describe IncomingMessage, " checking validity to reply to" do |