diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/media_attachment_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/models/media_attachment_spec.rb b/spec/models/media_attachment_spec.rb index d98f7e696..f6717b7d5 100644 --- a/spec/models/media_attachment_spec.rb +++ b/spec/models/media_attachment_spec.rb @@ -11,6 +11,13 @@ RSpec.describe MediaAttachment, type: :model do it 'converts original file to mp4' do expect(media.file_content_type).to eq 'video/mp4' end + + it 'sets meta' do + expect(media.file.meta["original"]["width"]).to eq 128 + expect(media.file.meta["original"]["height"]).to eq 128 + expect(media.file.meta["original"]["aspect"]).to eq 1.0 + end + end describe 'non-animated gif non-conversion' do @@ -23,5 +30,24 @@ RSpec.describe MediaAttachment, type: :model do it 'leaves original file as-is' do expect(media.file_content_type).to eq 'image/gif' end + + it 'sets meta' do + 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 + end + end + + describe 'jpeg' do + let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture('attachment.jpg')) } + + it 'sets meta for different style' do + 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 + expect(media.file.meta["small"]["width"]).to eq 400 + expect(media.file.meta["small"]["height"]).to eq 267 + expect(media.file.meta["small"]["aspect"]).to eq 400.0/267 + end end end |