From f8b367cc9cf36f57e63c7b0a6653ce76360b3274 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Thu, 26 Jul 2018 10:17:38 +0800 Subject: [PATCH] Fix the build. --- app/models/optimized_image.rb | 6 +++--- spec/models/optimized_image_spec.rb | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/optimized_image.rb b/app/models/optimized_image.rb index 663e0662c22..23ae4823d8f 100644 --- a/app/models/optimized_image.rb +++ b/app/models/optimized_image.rb @@ -244,15 +244,15 @@ class OptimizedImage < ActiveRecord::Base method_name += "_animated" end instructions = self.send(method_name.to_sym, from, to, dimensions, opts) - convert_with(instructions, to) + convert_with(instructions, to, opts) end - def self.convert_with(instructions, to) + def self.convert_with(instructions, to, opts = {}) Discourse::Utils.execute_command(*instructions) FileHelper.optimize_image!(to) true rescue => e - if Rails.env.test? + if opts[:raise_on_error] raise e else Rails.logger.error("Could not optimize image #{to}: #{e.message}") diff --git a/spec/models/optimized_image_spec.rb b/spec/models/optimized_image_spec.rb index 60441d872f0..beb94b02ff6 100644 --- a/spec/models/optimized_image_spec.rb +++ b/spec/models/optimized_image_spec.rb @@ -56,7 +56,8 @@ describe OptimizedImage do "#{Rails.root}/spec/fixtures/images/svg.png", tmp_path, 5, - 5 + 5, + raise_on_error: true ) end.to raise_error(RuntimeError, /improper image header/) ensure