You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.4 KiB

  1. require 'rails_helper'
  2. describe Admin::ReportedStatusesController do
  3. render_views
  4. let(:user) { Fabricate(:user, admin: true) }
  5. let(:report) { Fabricate(:report, status_ids: [status.id]) }
  6. let(:status) { Fabricate(:status) }
  7. before do
  8. sign_in user, scope: :user
  9. end
  10. describe 'PATCH #update' do
  11. subject do
  12. -> { patch :update, params: { report_id: report, id: status, status: { sensitive: sensitive } } }
  13. end
  14. let(:status) { Fabricate(:status, sensitive: !sensitive) }
  15. let(:sensitive) { true }
  16. context 'updates sensitive column to true' do
  17. it 'updates sensitive column' do
  18. is_expected.to change {
  19. status.reload.sensitive
  20. }.from(false).to(true)
  21. end
  22. end
  23. context 'updates sensitive column to false' do
  24. let(:sensitive) { false }
  25. it 'updates sensitive column' do
  26. is_expected.to change {
  27. status.reload.sensitive
  28. }.from(true).to(false)
  29. end
  30. end
  31. it 'redirects to report page' do
  32. subject.call
  33. expect(response).to redirect_to(admin_report_path(report))
  34. end
  35. end
  36. describe 'DELETE #destroy' do
  37. it 'removes a status' do
  38. allow(RemovalWorker).to receive(:perform_async)
  39. delete :destroy, params: { report_id: report, id: status }
  40. expect(response).to redirect_to(admin_report_path(report))
  41. expect(RemovalWorker).
  42. to have_received(:perform_async).with(status.id)
  43. end
  44. end
  45. end