Reduce RSpec/MultipleExpectations
in media_attachment spec (#29228)
This commit is contained in:
parent
e140d05a6a
commit
bba488c189
1 changed files with 25 additions and 24 deletions
|
@ -91,20 +91,15 @@ RSpec.describe MediaAttachment, :paperclip_processing do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'saves media attachment with correct file metadata' do
|
it 'saves media attachment with correct file metadata' do
|
||||||
expect(media.persisted?).to be true
|
expect(media)
|
||||||
expect(media.file).to_not be_nil
|
.to be_persisted
|
||||||
|
.and be_processing_complete
|
||||||
# completes processing
|
.and have_attributes(
|
||||||
expect(media.processing_complete?).to be true
|
file: be_present,
|
||||||
|
type: eq('image'),
|
||||||
# sets type
|
file_content_type: eq(content_type),
|
||||||
expect(media.type).to eq 'image'
|
file_file_name: end_with(extension)
|
||||||
|
)
|
||||||
# sets content type
|
|
||||||
expect(media.file_content_type).to eq content_type
|
|
||||||
|
|
||||||
# sets file extension
|
|
||||||
expect(media.file_file_name).to end_with extension
|
|
||||||
|
|
||||||
# Rack::Mime (used by PublicFileServerMiddleware) recognizes file extension
|
# Rack::Mime (used by PublicFileServerMiddleware) recognizes file extension
|
||||||
expect(Rack::Mime.mime_type(extension, nil)).to eq content_type
|
expect(Rack::Mime.mime_type(extension, nil)).to eq content_type
|
||||||
|
@ -112,17 +107,23 @@ RSpec.describe MediaAttachment, :paperclip_processing do
|
||||||
|
|
||||||
it 'saves media attachment with correct size metadata' do
|
it 'saves media attachment with correct size metadata' do
|
||||||
# strips original file name
|
# strips original file name
|
||||||
expect(media.file_file_name).to_not start_with '600x400'
|
expect(media.file_file_name)
|
||||||
|
.to_not start_with '600x400'
|
||||||
|
|
||||||
# sets meta for original
|
# sets meta for original and thumbnail
|
||||||
expect(media.file.meta['original']['width']).to eq 600
|
expect(media.file.meta.deep_symbolize_keys)
|
||||||
expect(media.file.meta['original']['height']).to eq 400
|
.to include(
|
||||||
expect(media.file.meta['original']['aspect']).to eq 1.5
|
original: include(
|
||||||
|
width: eq(600),
|
||||||
# sets meta for thumbnail
|
height: eq(400),
|
||||||
expect(media.file.meta['small']['width']).to eq 588
|
aspect: eq(1.5)
|
||||||
expect(media.file.meta['small']['height']).to eq 392
|
),
|
||||||
expect(media.file.meta['small']['aspect']).to eq 1.5
|
small: include(
|
||||||
|
width: eq(588),
|
||||||
|
height: eq(392),
|
||||||
|
aspect: eq(1.5)
|
||||||
|
)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue