aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gemfile3
-rw-r--r--Gemfile.lock4
-rw-r--r--app/assets/javascripts/general.js2
-rw-r--r--lib/attachment_to_html/adapters/pdf.rb3
-rw-r--r--spec/lib/attachment_to_html/adapters/pdf_spec.rb5
5 files changed, 11 insertions, 6 deletions
diff --git a/Gemfile b/Gemfile
index eca861681..d6ae34296 100644
--- a/Gemfile
+++ b/Gemfile
@@ -26,8 +26,7 @@ gem 'rack', '~> 1.4.5'
gem 'rake', '0.9.2.2'
gem 'rails-i18n', '~> 0.7.3'
gem 'recaptcha', '~> 0.3.1', :require => 'recaptcha/rails'
-# :require avoids "already initialized constant" warnings
-gem 'rmagick', '~> 2.13.2', :require => 'RMagick'
+gem 'rmagick', '~> 2.14.0'
gem 'ruby-msg', '~> 1.5.0', :git => 'git://github.com/mysociety/ruby-msg.git'
gem 'secure_headers', '~> 1.3.4'
gem 'statistics2', '~> 0.54'
diff --git a/Gemfile.lock b/Gemfile.lock
index 2f88a474e..64d7aec82 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -216,7 +216,7 @@ GEM
ref (1.0.5)
rest-client (1.6.7)
mime-types (>= 1.16)
- rmagick (2.13.2)
+ rmagick (2.14.0)
routing-filter (0.3.1)
actionpack
rspec-core (2.13.1)
@@ -342,7 +342,7 @@ DEPENDENCIES
rake (= 0.9.2.2)
rdoc (~> 3.12.2)
recaptcha (~> 0.3.1)
- rmagick (~> 2.13.2)
+ rmagick (~> 2.14.0)
routing-filter (~> 0.3.1)
rspec-rails (~> 2.13.2)
ruby-debug (~> 0.10.4)
diff --git a/app/assets/javascripts/general.js b/app/assets/javascripts/general.js
index 002eef760..856f4c6d4 100644
--- a/app/assets/javascripts/general.js
+++ b/app/assets/javascripts/general.js
@@ -34,12 +34,12 @@ $(document).ready(function() {
box.width(location.length + " em");
box.find('input').val(location).attr('size', location.length + " em");
box.show();
- box.find('input').select();
box.position({
my: "right center",
at: "left bottom",
of: this,
collision: "fit" });
+ box.find('input').select();
return false;
});
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