]> cat aescling's git repositories - mastodon.git/blob - spec/controllers/media_proxy_controller_spec.rb
Fix admins being able to suspend their instance actor (#14567)
[mastodon.git] / spec / controllers / media_proxy_controller_spec.rb
1 # frozen_string_literal: true
2
3 require 'rails_helper'
4
5 describe MediaProxyController do
6 render_views
7
8 before do
9 stub_request(:get, 'http://example.com/attachment.png').to_return(request_fixture('avatar.txt'))
10 end
11
12 describe '#show' do
13 it 'redirects when attached to a status' do
14 status = Fabricate(:status)
15 media_attachment = Fabricate(:media_attachment, status: status, remote_url: 'http://example.com/attachment.png')
16 get :show, params: { id: media_attachment.id }
17
18 expect(response).to have_http_status(302)
19 end
20
21 it 'responds with missing when there is not an attached status' do
22 media_attachment = Fabricate(:media_attachment, status: nil, remote_url: 'http://example.com/attachment.png')
23 get :show, params: { id: media_attachment.id }
24
25 expect(response).to have_http_status(404)
26 end
27
28 it 'raises when id cant be found' do
29 get :show, params: { id: 'missing' }
30
31 expect(response).to have_http_status(404)
32 end
33
34 it 'raises when not permitted to view' do
35 status = Fabricate(:status, visibility: :direct)
36 media_attachment = Fabricate(:media_attachment, status: status, remote_url: 'http://example.com/attachment.png')
37 get :show, params: { id: media_attachment.id }
38
39 expect(response).to have_http_status(404)
40 end
41 end
42 end
This page took 0.060335 seconds and 4 git commands to generate.