statuses_controller_spec.rb 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. require 'rails_helper'
  2. describe Admin::StatusesController do
  3. render_views
  4. let(:user) { Fabricate(:user, admin: true) }
  5. let(:account) { Fabricate(:account) }
  6. let!(:status) { Fabricate(:status, account: account) }
  7. let(:media_attached_status) { Fabricate(:status, account: account, sensitive: !sensitive) }
  8. let!(:media_attachment) { Fabricate(:media_attachment, account: account, status: media_attached_status) }
  9. let(:last_media_attached_status) { Fabricate(:status, account: account, sensitive: !sensitive) }
  10. let!(:last_media_attachment) { Fabricate(:media_attachment, account: account, status: last_media_attached_status) }
  11. let!(:last_status) { Fabricate(:status, account: account) }
  12. let(:sensitive) { true }
  13. before do
  14. sign_in user, scope: :user
  15. end
  16. describe 'GET #index' do
  17. context do
  18. before do
  19. get :index, params: { account_id: account.id }
  20. end
  21. it 'returns http success' do
  22. expect(response).to have_http_status(200)
  23. end
  24. end
  25. context 'filtering by media' do
  26. before do
  27. get :index, params: { account_id: account.id, media: '1' }
  28. end
  29. it 'returns http success' do
  30. expect(response).to have_http_status(200)
  31. end
  32. end
  33. end
  34. describe 'POST #batch' do
  35. before do
  36. post :batch, params: { :account_id => account.id, action => '', :admin_status_batch_action => { status_ids: status_ids } }
  37. end
  38. let(:status_ids) { [media_attached_status.id] }
  39. context 'when action is report' do
  40. let(:action) { 'report' }
  41. it 'creates a report' do
  42. report = Report.last
  43. expect(report.target_account_id).to eq account.id
  44. expect(report.status_ids).to eq status_ids
  45. end
  46. it 'redirects to report page' do
  47. expect(response).to redirect_to(admin_report_path(Report.last.id))
  48. end
  49. end
  50. end
  51. end