diff options
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/alaveteli_external_command.rb | 23 | ||||
-rwxr-xr-x | spec/lib/alaveteli_external_command_scripts/error.sh | 4 | ||||
-rwxr-xr-x | spec/lib/alaveteli_external_command_scripts/segfault.sh | 3 | ||||
-rw-r--r-- | spec/lib/mail_handler/mail_handler_spec.rb | 6 |
4 files changed, 36 insertions, 0 deletions
diff --git a/spec/lib/alaveteli_external_command.rb b/spec/lib/alaveteli_external_command.rb new file mode 100644 index 000000000..18afeda33 --- /dev/null +++ b/spec/lib/alaveteli_external_command.rb @@ -0,0 +1,23 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +require 'alaveteli_external_command' + +script_dir = File.join(File.dirname(__FILE__), 'alaveteli_external_command_scripts') +segfault_script = File.join(script_dir, 'segfault.sh') +error_script = File.join(script_dir, 'error.sh') + +describe "when running external commands" do + + it "should detect a non-zero exit status" do + $stderr.should_receive(:puts).with(/Error from/) + t = AlaveteliExternalCommand.run(error_script) + assert_nil t + end + + it "should detect when an external command crashes" do + $stderr.should_receive(:puts).with(/exited abnormally/) + t = AlaveteliExternalCommand.run(segfault_script) + assert_nil t + end + +end diff --git a/spec/lib/alaveteli_external_command_scripts/error.sh b/spec/lib/alaveteli_external_command_scripts/error.sh new file mode 100755 index 000000000..65e74b3c6 --- /dev/null +++ b/spec/lib/alaveteli_external_command_scripts/error.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "this is my error message" >&1 +exit 1 diff --git a/spec/lib/alaveteli_external_command_scripts/segfault.sh b/spec/lib/alaveteli_external_command_scripts/segfault.sh new file mode 100755 index 000000000..f96ba5be8 --- /dev/null +++ b/spec/lib/alaveteli_external_command_scripts/segfault.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +kill -11 $$ diff --git a/spec/lib/mail_handler/mail_handler_spec.rb b/spec/lib/mail_handler/mail_handler_spec.rb index bc027eaec..49a65dade 100644 --- a/spec/lib/mail_handler/mail_handler_spec.rb +++ b/spec/lib/mail_handler/mail_handler_spec.rb @@ -409,6 +409,12 @@ describe 'when getting attachment attributes' do attributes[1][:body].length.should == 7769 end + it 'should treat a document/pdf attachment as application/pdf' do + mail = get_fixture_mail('document-pdf.email') + attributes = MailHandler.get_attachment_attributes(mail) + attributes[1][:content_type].should == "application/pdf" + end + it 'should produce a consistent set of url_part_numbers, content_types, within_rfc822_subjects and filenames from an example mail with lots of attachments' do mail = get_fixture_mail('many-attachments-date-header.email') |