mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-19 16:07:08 +00:00
Reduce RSpec/MultipleExpectations
in media_attachment spec (#29228)
This commit is contained in:
parent
e140d05a6a
commit
bba488c189
|
@ -91,20 +91,15 @@ RSpec.describe MediaAttachment, :paperclip_processing do
|
|||
end
|
||||
|
||||
it 'saves media attachment with correct file metadata' do
|
||||
expect(media.persisted?).to be true
|
||||
expect(media.file).to_not be_nil
|
||||
|
||||
# completes processing
|
||||
expect(media.processing_complete?).to be true
|
||||
|
||||
# sets type
|
||||
expect(media.type).to eq 'image'
|
||||
|
||||
# sets content type
|
||||
expect(media.file_content_type).to eq content_type
|
||||
|
||||
# sets file extension
|
||||
expect(media.file_file_name).to end_with extension
|
||||
expect(media)
|
||||
.to be_persisted
|
||||
.and be_processing_complete
|
||||
.and have_attributes(
|
||||
file: be_present,
|
||||
type: eq('image'),
|
||||
file_content_type: eq(content_type),
|
||||
file_file_name: end_with(extension)
|
||||
)
|
||||
|
||||
# Rack::Mime (used by PublicFileServerMiddleware) recognizes file extension
|
||||
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
|
||||
# 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
|
||||
expect(media.file.meta['original']['width']).to eq 600
|
||||
expect(media.file.meta['original']['height']).to eq 400
|
||||
expect(media.file.meta['original']['aspect']).to eq 1.5
|
||||
|
||||
# sets meta for thumbnail
|
||||
expect(media.file.meta['small']['width']).to eq 588
|
||||
expect(media.file.meta['small']['height']).to eq 392
|
||||
expect(media.file.meta['small']['aspect']).to eq 1.5
|
||||
# sets meta for original and thumbnail
|
||||
expect(media.file.meta.deep_symbolize_keys)
|
||||
.to include(
|
||||
original: include(
|
||||
width: eq(600),
|
||||
height: eq(400),
|
||||
aspect: eq(1.5)
|
||||
),
|
||||
small: include(
|
||||
width: eq(588),
|
||||
height: eq(392),
|
||||
aspect: eq(1.5)
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue