statuses_controller_spec.rb 1.9 KB

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