Fix tests
This commit is contained in:
parent
46db6a6340
commit
3ad653c4fd
|
@ -15,14 +15,14 @@ describe MediaController do
|
|||
context 'when the media attachment has a shortcode' do
|
||||
it 'redirects to the file url when attached to a status' do
|
||||
status = Fabricate(:status)
|
||||
media_attachment = Fabricate(:media_attachment, status: status, shortcode: 'foo')
|
||||
media_attachment = Fabricate(:media_attachment, status: status, shortcode: 'OI6IgDzG-nYTqvDQ994')
|
||||
get :show, params: { id: media_attachment.to_param }
|
||||
|
||||
expect(response).to redirect_to(media_attachment.file.url(:original))
|
||||
end
|
||||
|
||||
it 'responds with missing when there is not an attached status' do
|
||||
media_attachment = Fabricate(:media_attachment, status: nil, shortcode: 'foo')
|
||||
media_attachment = Fabricate(:media_attachment, status: nil, shortcode: 'OI6IgDzG-nYTqvDQ994')
|
||||
get :show, params: { id: media_attachment.to_param }
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
|
@ -30,7 +30,7 @@ describe MediaController do
|
|||
|
||||
it 'raises when not permitted to view' do
|
||||
status = Fabricate(:status, visibility: :direct)
|
||||
media_attachment = Fabricate(:media_attachment, status: status, shortcode: 'foo')
|
||||
media_attachment = Fabricate(:media_attachment, status: status, shortcode: 'OI6IgDzG-nYTqvDQ994')
|
||||
get :show, params: { id: media_attachment.to_param }
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
|
|
|
@ -62,14 +62,26 @@ RSpec.describe MediaAttachment, type: :model do
|
|||
end
|
||||
|
||||
describe '#to_param' do
|
||||
let(:media_attachment) { Fabricate(:media_attachment) }
|
||||
let(:shortcode) { media_attachment.shortcode }
|
||||
let(:media_attachment) { Fabricate(:media_attachment, shortcode: shortcode) }
|
||||
let(:shortcode) { nil }
|
||||
|
||||
context 'when media attachment has a shortcode' do
|
||||
let(:shortcode) { 'foo' }
|
||||
|
||||
it 'returns shortcode' do
|
||||
expect(media_attachment.to_param).to eq shortcode
|
||||
end
|
||||
end
|
||||
|
||||
context 'when media attachment does not have a shortcode' do
|
||||
let(:shortcode) { nil }
|
||||
|
||||
it 'returns string representation of id' do
|
||||
expect(media_attachment.to_param).to eq media_attachment.id.to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'animated gif conversion' do
|
||||
let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture('avatar.gif')) }
|
||||
|
||||
|
|
Reference in New Issue