logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

media_controller_spec.rb (1237B)


  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe MediaController do
  4. render_views
  5. describe '#show' do
  6. it 'redirects to the file url when attached to a status' do
  7. status = Fabricate(:status)
  8. media_attachment = Fabricate(:media_attachment, status: status)
  9. get :show, params: { id: media_attachment.to_param }
  10. expect(response).to redirect_to(media_attachment.file.url(:original))
  11. end
  12. it 'responds with missing when there is not an attached status' do
  13. media_attachment = Fabricate(:media_attachment, status: nil)
  14. get :show, params: { id: media_attachment.to_param }
  15. expect(response).to have_http_status(:missing)
  16. end
  17. it 'raises when shortcode cant be found' do
  18. get :show, params: { id: 'missing' }
  19. expect(response).to have_http_status(:missing)
  20. end
  21. it 'raises when not permitted to view' do
  22. status = Fabricate(:status)
  23. media_attachment = Fabricate(:media_attachment, status: status)
  24. allow_any_instance_of(MediaController).to receive(:authorize).and_raise(ActiveRecord::RecordNotFound)
  25. get :show, params: { id: media_attachment.to_param }
  26. expect(response).to have_http_status(:missing)
  27. end
  28. end
  29. end