Skip to content

Commit

Permalink
Do not enable image cropper if file is missing (#1903)
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdeyen authored Jul 17, 2020
1 parent dc51e11 commit 3ede2b6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/alchemy/essence_picture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
16 changes: 14 additions & 2 deletions spec/models/alchemy/essence_picture_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3ede2b6

Please sign in to comment.