about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorunarist <m.unarist@gmail.com>2017-10-26 22:48:35 +0900
committerGitHub <noreply@github.com>2017-10-26 22:48:35 +0900
commit4f337c020a7ca7a77086af5021c9c152fa1f07fc (patch)
tree02a9e15905b981712e9dc056123f760b42e21065 /spec
parent02f7f3619a2af35ec29aface76bd6b5ba0f1a725 (diff)
Fix Cocaine::ExitStatusError when upload small non-animated GIF (#5489)
Looks like copied tempfile need to be flushed before further processing. This issue won't happen if the uploaded file has enough file size.
Diffstat (limited to 'spec')
-rw-r--r--spec/fixtures/files/mini-static.gifbin0 -> 1188 bytes
-rw-r--r--spec/models/media_attachment_spec.rb31
2 files changed, 20 insertions, 11 deletions
diff --git a/spec/fixtures/files/mini-static.gif b/spec/fixtures/files/mini-static.gif
new file mode 100644
index 000000000..fe597b215
--- /dev/null
+++ b/spec/fixtures/files/mini-static.gif
Binary files differdiff --git a/spec/models/media_attachment_spec.rb b/spec/models/media_attachment_spec.rb
index 9fce5bc4f..435b4f326 100644
--- a/spec/models/media_attachment_spec.rb
+++ b/spec/models/media_attachment_spec.rb
@@ -20,20 +20,29 @@ RSpec.describe MediaAttachment, type: :model do
   end
 
   describe 'non-animated gif non-conversion' do
-    let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture('attachment.gif')) }
+    fixtures = [
+      { filename: 'attachment.gif', width: 600, height: 400, aspect: 1.5 },
+      { filename: 'mini-static.gif', width: 32, height: 32, aspect: 1.0 },
+    ]
 
-    it 'sets type to image' do
-      expect(media.type).to eq 'image'
-    end
+    fixtures.each do |fixture|
+      context fixture[:filename] do
+        let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture(fixture[:filename])) }
 
-    it 'leaves original file as-is' do
-      expect(media.file_content_type).to eq 'image/gif'
-    end
+        it 'sets type to image' do
+          expect(media.type).to eq 'image'
+        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
+        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 fixture[:width]
+          expect(media.file.meta["original"]["height"]).to eq fixture[:height]
+          expect(media.file.meta["original"]["aspect"]).to eq fixture[:aspect]
+        end
+      end
     end
   end