]> cat aescling's git repositories - mastodon.git/commitdiff
Update fabricator for MediaAttachment to attach a file according to type (#3862)
authorAkihiko Odaki (@fn_aki@pawoo.net) <akihiko.odaki.4i@stu.hosei.ac.jp>
Tue, 20 Jun 2017 18:40:45 +0000 (03:40 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Tue, 20 Jun 2017 18:40:45 +0000 (20:40 +0200)
This fixes a random spec failures since commit
d55f207274648369cba30ff001aa3e354fa30dca.

spec/fabricators/media_attachment_fabricator.rb

index c5dfe12e53a11d71608e90beb1625a263dfa583e..bb938e36d9825d6bbd9f1769d84e04731bf9889b 100644 (file)
@@ -1,4 +1,16 @@
 Fabricator(:media_attachment) do
   account
-  file { [attachment_fixture(['attachment.gif', 'attachment.jpg', 'attachment.webm'].sample), nil].sample }
+  file do |attrs|
+    [
+      case attrs[:type]
+      when :gifv
+        attachment_fixture ['attachment.gif', 'attachment.webm'].sample
+      when :image
+        attachment_fixture 'attachment.jpg'
+      when nil
+        attachment_fixture ['attachment.gif', 'attachment.jpg', 'attachment.webm'].sample
+      end,
+      nil
+    ].sample
+  end
 end