-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4318 from solidusio/waiting-for-dev/active_storag…
…e_size Fixes defining thumbnail sizes through ActiveStorage adapter
- Loading branch information
Showing
2 changed files
with
83 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
core/spec/models/spree/concerns/active_storage_adapter/attachment_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
unless ENV['DISABLE_ACTIVE_STORAGE'] | ||
RSpec.describe Spree::ActiveStorageAdapter::Attachment do | ||
describe '#variant' do | ||
it "converts to resize_to_limit when definition doesn't contain any special symbol" do | ||
image = create(:image) | ||
|
||
attachment = described_class.new(image.attachment.attachment, styles: { mini: '10x10' }) | ||
|
||
expect( | ||
attachment.variant(:mini).variation.transformations | ||
).to include(resize_to_limit: [10, 10]) | ||
end | ||
|
||
it 'converts to resize_to_limit when definition ends with >' do | ||
image = create(:image) | ||
|
||
attachment = described_class.new(image.attachment.attachment, styles: { mini: '10x10>' }) | ||
|
||
expect( | ||
attachment.variant(:mini).variation.transformations | ||
).to include(resize_to_limit: [10, 10]) | ||
end | ||
|
||
it 'converts to resize_to_fill when definition ends with ^' do | ||
image = create(:image) | ||
|
||
attachment = described_class.new(image.attachment.attachment, styles: { mini: '10x10^' }) | ||
|
||
expect( | ||
attachment.variant(:mini).variation.transformations | ||
).to include(resize_to_fill: [10, 10]) | ||
end | ||
|
||
it 'strips definitions' do | ||
image = create(:image) | ||
|
||
attachment = described_class.new(image.attachment.attachment, styles: { mini: ' 10x10 ' }) | ||
|
||
expect( | ||
attachment.variant(:mini).variation.transformations | ||
).to include(resize_to_limit: [10, 10]) | ||
end | ||
|
||
|
||
it "defaults to the image's width and height" do | ||
image = create(:image) | ||
|
||
attachment = described_class.new(image.attachment.attachment, styles: {}) | ||
|
||
expect( | ||
attachment.variant(:mini).variation.transformations | ||
).to include(resize_to_limit: [attachment.width, attachment.height]) | ||
end | ||
end | ||
end | ||
end |