about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorEugen <eugen@zeonfederated.com>2017-04-19 23:21:00 +0200
committerGitHub <noreply@github.com>2017-04-19 23:21:00 +0200
commit2e4afccd9d5327c072cf0a0fe5d4c6e97ecc10cf (patch)
tree1f7c6a8b165d65b1d50f635af683251400c9ce34 /spec
parent0876a06e4544bc0946f3f6d884c7e2507ee12def (diff)
Fix #2108 - Fix gif uploads (#2171)
* Fix #2108 - Fix gif uploads
Add specs for media attachment gifv conversion

* Add ffmpeg to travis

* Make travis install ffmpeg, not libav

* Switch travis to trusty
Diffstat (limited to 'spec')
-rw-r--r--spec/fixtures/files/attachment.gifbin0 -> 108560 bytes
-rw-r--r--spec/models/media_attachment_spec.rb22
2 files changed, 22 insertions, 0 deletions
diff --git a/spec/fixtures/files/attachment.gif b/spec/fixtures/files/attachment.gif
new file mode 100644
index 000000000..2937f5abe
--- /dev/null
+++ b/spec/fixtures/files/attachment.gif
Binary files differdiff --git a/spec/models/media_attachment_spec.rb b/spec/models/media_attachment_spec.rb
index 5995aa4f4..d98f7e696 100644
--- a/spec/models/media_attachment_spec.rb
+++ b/spec/models/media_attachment_spec.rb
@@ -1,5 +1,27 @@
 require 'rails_helper'
 
 RSpec.describe MediaAttachment, type: :model do
+  describe 'animated gif conversion' do
+    let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture('avatar.gif')) }
 
+    it 'sets type to gifv' do
+      expect(media.type).to eq 'gifv'
+    end
+
+    it 'converts original file to mp4' do
+      expect(media.file_content_type).to eq 'video/mp4'
+    end
+  end
+
+  describe 'non-animated gif non-conversion' do
+    let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture('attachment.gif')) }
+
+    it 'sets type to image' do
+      expect(media.type).to eq 'image'
+    end
+
+    it 'leaves original file as-is' do
+      expect(media.file_content_type).to eq 'image/gif'
+    end
+  end
 end