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.

59 lines
1.5 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 'POST #create' do
  11. subject do
  12. -> { post :create, params: { :report_id => report, action => '', :form_status_batch => { status_ids: status_ids } } }
  13. end
  14. let(:action) { 'nsfw_on' }
  15. let(:status_ids) { [status.id] }
  16. let(:status) { Fabricate(:status, sensitive: !sensitive) }
  17. let(:sensitive) { true }
  18. let!(:media_attachment) { Fabricate(:media_attachment, status: status) }
  19. context 'when action is nsfw_on' do
  20. it 'updates sensitive column' do
  21. is_expected.to change {
  22. status.reload.sensitive
  23. }.from(false).to(true)
  24. end
  25. end
  26. context 'when action is nsfw_off' do
  27. let(:action) { 'nsfw_off' }
  28. let(:sensitive) { false }
  29. it 'updates sensitive column' do
  30. is_expected.to change {
  31. status.reload.sensitive
  32. }.from(true).to(false)
  33. end
  34. end
  35. context 'when action is delete' do
  36. let(:action) { 'delete' }
  37. it 'removes a status' do
  38. allow(RemovalWorker).to receive(:perform_async)
  39. subject.call
  40. expect(RemovalWorker).to have_received(:perform_async).with(status_ids.first)
  41. end
  42. end
  43. it 'redirects to report page' do
  44. subject.call
  45. expect(response).to redirect_to(admin_report_path(report))
  46. end
  47. end
  48. end