1 # frozen_string_literal: true
5 describe MediaProxyController
do
9 stub_request(:get, 'http://example.com/attachment.png').to_return(request_fixture('avatar.txt'))
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
}
18 expect(response
).to
have_http_status(302)
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
}
25 expect(response
).to
have_http_status(404)
28 it
'raises when id cant be found' do
29 get
:show, params
: { id
: 'missing' }
31 expect(response
).to
have_http_status(404)
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
}
39 expect(response
).to
have_http_status(404)