Skip to content

Commit 585545d

Browse files
authored
Add coverage for media#player scenarios (mastodon#35947)
1 parent d967137 commit 585545d

2 files changed

Lines changed: 49 additions & 8 deletions

File tree

spec/requests/media_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,17 @@
8787
end
8888
end
8989
end
90+
91+
describe 'GET /media/:medium_id/player' do
92+
context 'when media type is not large format type' do
93+
let(:media) { Fabricate :media_attachment }
94+
95+
it 'responds with not found' do
96+
get medium_player_path(media)
97+
98+
expect(response)
99+
.to have_http_status(404)
100+
end
101+
end
102+
end
90103
end

spec/system/media_spec.rb

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,47 @@
44

55
RSpec.describe 'Media' do
66
describe 'Player page' do
7+
let(:status) { Fabricate :status }
8+
9+
before { status.media_attachments << media }
10+
711
context 'when signed in' do
812
before { sign_in Fabricate(:user) }
913

10-
it 'visits the media player page and renders the media' do
11-
status = Fabricate :status
12-
media = Fabricate :media_attachment, type: :video
13-
status.media_attachments << media
14+
context 'when media type is video' do
15+
let(:media) { Fabricate :media_attachment, type: :video }
16+
17+
it 'visits the player page and renders media' do
18+
visit medium_player_path(media)
19+
20+
expect(page)
21+
.to have_css('body', class: 'player')
22+
.and have_css('div[data-component="Video"] video[controls="controls"] source')
23+
end
24+
end
25+
26+
context 'when media type is gifv' do
27+
let(:media) { Fabricate :media_attachment, type: :gifv }
28+
29+
it 'visits the player page and renders media' do
30+
visit medium_player_path(media)
31+
32+
expect(page)
33+
.to have_css('body', class: 'player')
34+
.and have_css('div[data-component="MediaGallery"] video[loop="loop"] source')
35+
end
36+
end
37+
38+
context 'when media type is audio' do
39+
let(:media) { Fabricate :media_attachment, type: :audio }
1440

15-
visit medium_player_path(media)
41+
it 'visits the player page and renders media' do
42+
visit medium_player_path(media)
1643

17-
expect(page)
18-
.to have_css('body', class: 'player')
19-
.and have_css('div[data-component="Video"]')
44+
expect(page)
45+
.to have_css('body', class: 'player')
46+
.and have_css('div[data-component="Audio"] audio source')
47+
end
2048
end
2149
end
2250
end

0 commit comments

Comments
 (0)