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
|
context 'when the media attachment has a shortcode' do
|
||||||
it 'redirects to the file url when attached to a status' do
|
it 'redirects to the file url when attached to a status' do
|
||||||
status = Fabricate(:status)
|
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 }
|
get :show, params: { id: media_attachment.to_param }
|
||||||
|
|
||||||
expect(response).to redirect_to(media_attachment.file.url(:original))
|
expect(response).to redirect_to(media_attachment.file.url(:original))
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'responds with missing when there is not an attached status' do
|
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 }
|
get :show, params: { id: media_attachment.to_param }
|
||||||
|
|
||||||
expect(response).to have_http_status(404)
|
expect(response).to have_http_status(404)
|
||||||
|
@ -30,7 +30,7 @@ describe MediaController do
|
||||||
|
|
||||||
it 'raises when not permitted to view' do
|
it 'raises when not permitted to view' do
|
||||||
status = Fabricate(:status, visibility: :direct)
|
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 }
|
get :show, params: { id: media_attachment.to_param }
|
||||||
|
|
||||||
expect(response).to have_http_status(404)
|
expect(response).to have_http_status(404)
|
||||||
|
|
|
@ -62,11 +62,23 @@ RSpec.describe MediaAttachment, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#to_param' do
|
describe '#to_param' do
|
||||||
let(:media_attachment) { Fabricate(:media_attachment) }
|
let(:media_attachment) { Fabricate(:media_attachment, shortcode: shortcode) }
|
||||||
let(:shortcode) { media_attachment.shortcode }
|
let(:shortcode) { nil }
|
||||||
|
|
||||||
it 'returns shortcode' do
|
context 'when media attachment has a shortcode' do
|
||||||
expect(media_attachment.to_param).to eq shortcode
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Reference in New Issue