From 12b0abe713e1423e2409be9cde5aca265d604d71 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 28 Aug 2025 08:42:15 -0400 Subject: [PATCH 1/2] Add coverage for non large format media --- spec/requests/media_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/requests/media_spec.rb b/spec/requests/media_spec.rb index a448a87492e..523c4689d6a 100644 --- a/spec/requests/media_spec.rb +++ b/spec/requests/media_spec.rb @@ -87,4 +87,17 @@ RSpec.describe 'Media' do end end end + + describe 'GET /media/:medium_id/player' do + context 'when media type is not large format type' do + let(:media) { Fabricate :media_attachment } + + it 'responds with not found' do + get medium_player_path(media) + + expect(response) + .to have_http_status(404) + end + end + end end From eb9e1074af7b1e4e35a6ff5e403fcf22bb172026 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 28 Aug 2025 08:42:28 -0400 Subject: [PATCH 2/2] Coverage for different media types on player --- spec/system/media_spec.rb | 44 ++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/spec/system/media_spec.rb b/spec/system/media_spec.rb index d014c7e88ef..ec069cdcaa9 100644 --- a/spec/system/media_spec.rb +++ b/spec/system/media_spec.rb @@ -4,19 +4,47 @@ require 'rails_helper' RSpec.describe 'Media' do describe 'Player page' do + let(:status) { Fabricate :status } + + before { status.media_attachments << media } + context 'when signed in' do before { sign_in Fabricate(:user) } - it 'visits the media player page and renders the media' do - status = Fabricate :status - media = Fabricate :media_attachment, type: :video - status.media_attachments << media + context 'when media type is video' do + let(:media) { Fabricate :media_attachment, type: :video } - visit medium_player_path(media) + it 'visits the player page and renders media' do + visit medium_player_path(media) - expect(page) - .to have_css('body', class: 'player') - .and have_css('div[data-component="Video"]') + expect(page) + .to have_css('body', class: 'player') + .and have_css('div[data-component="Video"] video[controls="controls"] source') + end + end + + context 'when media type is gifv' do + let(:media) { Fabricate :media_attachment, type: :gifv } + + it 'visits the player page and renders media' do + visit medium_player_path(media) + + expect(page) + .to have_css('body', class: 'player') + .and have_css('div[data-component="MediaGallery"] video[loop="loop"] source') + end + end + + context 'when media type is audio' do + let(:media) { Fabricate :media_attachment, type: :audio } + + it 'visits the player page and renders media' do + visit medium_player_path(media) + + expect(page) + .to have_css('body', class: 'player') + .and have_css('div[data-component="Audio"] audio source') + end end end end