diff --git a/app/models/alchemy/essence_picture.rb b/app/models/alchemy/essence_picture.rb index 82c1d5eeb1..7750e4d133 100644 --- a/app/models/alchemy/essence_picture.rb +++ b/app/models/alchemy/essence_picture.rb @@ -143,7 +143,7 @@ def allow_image_cropping? picture.can_be_cropped_to( content.settings[:size], content.settings[:upsample], - ) + ) && !!picture.image_file end def crop_values_present? diff --git a/spec/models/alchemy/essence_picture_spec.rb b/spec/models/alchemy/essence_picture_spec.rb index 3e539b0000..0367ac4abb 100644 --- a/spec/models/alchemy/essence_picture_spec.rb +++ b/spec/models/alchemy/essence_picture_spec.rb @@ -350,10 +350,22 @@ module Alchemy context "with crop set to true" do before do - allow(content).to receive(:settings) { {crop: true} } + allow(content).to receive(:settings) { { crop: true } } end - it { is_expected.to be(true) } + context "if picture.image_file is nil" do + before do + expect(picture).to receive(:image_file) { nil } + end + + it { is_expected.to be_falsy } + end + + context "if picture.image_file is present" do + let(:picture) { build_stubbed(:alchemy_picture) } + + it { is_expected.to be(true) } + end end end end