Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not enable image cropper if file is missing #1903

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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