2017-04-14 02:10:28 -07:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe Admin::ReportedStatusesController do
|
2017-04-28 06:12:37 -07:00
|
|
|
render_views
|
|
|
|
|
2017-04-14 02:10:28 -07:00
|
|
|
let(:user) { Fabricate(:user, admin: true) }
|
2017-05-23 10:45:43 -07:00
|
|
|
let(:report) { Fabricate(:report, status_ids: [status.id]) }
|
|
|
|
let(:status) { Fabricate(:status) }
|
|
|
|
|
2017-04-14 02:10:28 -07:00
|
|
|
before do
|
|
|
|
sign_in user, scope: :user
|
|
|
|
end
|
|
|
|
|
2017-07-18 07:38:22 -07:00
|
|
|
describe 'POST #create' do
|
|
|
|
subject do
|
2018-10-04 03:36:53 -07:00
|
|
|
-> { post :create, params: { :report_id => report, action => '', :form_status_batch => { status_ids: status_ids } } }
|
2017-07-18 07:38:22 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
let(:action) { 'nsfw_on' }
|
|
|
|
let(:status_ids) { [status.id] }
|
|
|
|
let(:status) { Fabricate(:status, sensitive: !sensitive) }
|
|
|
|
let(:sensitive) { true }
|
|
|
|
let!(:media_attachment) { Fabricate(:media_attachment, status: status) }
|
|
|
|
|
2018-05-05 14:06:29 -07:00
|
|
|
context 'when action is nsfw_on' do
|
2017-07-18 07:38:22 -07:00
|
|
|
it 'updates sensitive column' do
|
|
|
|
is_expected.to change {
|
|
|
|
status.reload.sensitive
|
|
|
|
}.from(false).to(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-05 14:06:29 -07:00
|
|
|
context 'when action is nsfw_off' do
|
2017-07-18 07:38:22 -07:00
|
|
|
let(:action) { 'nsfw_off' }
|
|
|
|
let(:sensitive) { false }
|
|
|
|
|
|
|
|
it 'updates sensitive column' do
|
|
|
|
is_expected.to change {
|
|
|
|
status.reload.sensitive
|
|
|
|
}.from(true).to(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-05 14:06:29 -07:00
|
|
|
context 'when action is delete' do
|
|
|
|
let(:action) { 'delete' }
|
2017-05-23 10:45:43 -07:00
|
|
|
|
2018-05-05 14:06:29 -07:00
|
|
|
it 'removes a status' do
|
|
|
|
allow(RemovalWorker).to receive(:perform_async)
|
|
|
|
subject.call
|
2019-09-11 07:32:44 -07:00
|
|
|
expect(RemovalWorker).to have_received(:perform_async).with(status_ids.first, immediate: true)
|
2017-05-23 10:45:43 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to report page' do
|
|
|
|
subject.call
|
|
|
|
expect(response).to redirect_to(admin_report_path(report))
|
|
|
|
end
|
|
|
|
end
|
2017-04-14 02:10:28 -07:00
|
|
|
end
|