aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/attachment_to_html/adapters/pdf.rb3
-rw-r--r--spec/lib/attachment_to_html/adapters/pdf_spec.rb5
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/attachment_to_html/adapters/pdf.rb b/lib/attachment_to_html/adapters/pdf.rb
index 3183d1fd0..3c18e9d4a 100644
--- a/lib/attachment_to_html/adapters/pdf.rb
+++ b/lib/attachment_to_html/adapters/pdf.rb
@@ -42,7 +42,8 @@ module AttachmentToHTML
private
def parse_body
- match = convert.match(/<body[^>]*>(.*?)<\/body>/mi)
+ conversion = convert
+ match = conversion ? conversion.match(/<body[^>]*>(.*?)<\/body>/mi) : nil
match ? match[1] : ''
end
diff --git a/spec/lib/attachment_to_html/adapters/pdf_spec.rb b/spec/lib/attachment_to_html/adapters/pdf_spec.rb
index f1ae4695c..ceb438be8 100644
--- a/spec/lib/attachment_to_html/adapters/pdf_spec.rb
+++ b/spec/lib/attachment_to_html/adapters/pdf_spec.rb
@@ -71,6 +71,11 @@ describe AttachmentToHTML::Adapters::PDF do
adapter.success?.should be_false
end
+ it 'is not successful if convert returns nil' do
+ adapter.stub(:convert).and_return(nil)
+ adapter.success?.should be_false
+ end
+
it 'is not successful if the body contains more than 50 images' do
# Sometimes pdftohtml extracts images incorrectly, resulting
# in thousands of PNGs being created for one image. This creates
> 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594