about summary refs log tree commit diff
path: root/spec/models/media_attachment_spec.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-09-30 00:29:38 +0200
committerGitHub <noreply@github.com>2021-09-30 00:29:38 +0200
commit5e36c3b44c052afb1aa61e2405c595c726bc9503 (patch)
tree899cb5f54098d08f28dad2c8ee555b3557dead16 /spec/models/media_attachment_spec.rb
parent00889b313176308018d66e54b5cb7dcc92da1587 (diff)
parent29b5c5f4830f9bda0af352b1d6ac73830a6cfd4e (diff)
Merge pull request #1612 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'spec/models/media_attachment_spec.rb')
-rw-r--r--spec/models/media_attachment_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/models/media_attachment_spec.rb b/spec/models/media_attachment_spec.rb
index 456bc4216..edab67d47 100644
--- a/spec/models/media_attachment_spec.rb
+++ b/spec/models/media_attachment_spec.rb
@@ -114,6 +114,30 @@ RSpec.describe MediaAttachment, type: :model do
     end
   end
 
+  describe 'ogg with cover art' do
+    let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture('boop.ogg')) }
+
+    it 'detects it as an audio file' do
+      expect(media.type).to eq 'audio'
+    end
+
+    it 'sets meta for the duration' do
+      expect(media.file.meta['original']['duration']).to be_within(0.05).of(0.235102)
+    end
+
+    it 'extracts thumbnail' do
+      expect(media.thumbnail.present?).to eq true
+    end
+
+    it 'extracts colors from thumbnail' do
+      expect(media.file.meta['colors']['background']).to eq '#3088d4'
+    end
+
+    it 'gives the file a random name' do
+      expect(media.file_file_name).to_not eq 'boop.ogg'
+    end
+  end
+
   describe 'jpeg' do
     let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture('attachment.jpg')) }