2017-04-14 19:10:28 +10:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe Admin::ReportedStatusesController do
|
2017-04-28 23:12:37 +10:00
|
|
|
render_views
|
|
|
|
|
2017-04-14 19:10:28 +10:00
|
|
|
let(:user) { Fabricate(:user, admin: true) }
|
2017-05-24 03:45:43 +10:00
|
|
|
let(:report) { Fabricate(:report, status_ids: [status.id]) }
|
|
|
|
let(:status) { Fabricate(:status) }
|
|
|
|
|
2017-04-14 19:10:28 +10:00
|
|
|
before do
|
|
|
|
sign_in user, scope: :user
|
|
|
|
end
|
|
|
|
|
2017-07-19 00:38:22 +10:00
|
|
|
describe 'POST #create' do
|
|
|
|
subject do
|
2018-10-04 20:36:53 +10:00
|
|
|
-> { post :create, params: { :report_id => report, action => '', :form_status_batch => { status_ids: status_ids } } }
|
2017-07-19 00:38:22 +10: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-06 07:06:29 +10:00
|
|
|
context 'when action is nsfw_on' do
|
2017-07-19 00:38:22 +10:00
|
|
|
it 'updates sensitive column' do
|
|
|
|
is_expected.to change {
|
|
|
|
status.reload.sensitive
|
|
|
|
}.from(false).to(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-06 07:06:29 +10:00
|
|
|
context 'when action is nsfw_off' do
|
2017-07-19 00:38:22 +10: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-06 07:06:29 +10:00
|
|
|
context 'when action is delete' do
|
|
|
|
let(:action) { 'delete' }
|
2017-05-24 03:45:43 +10:00
|
|
|
|
2018-05-06 07:06:29 +10:00
|
|
|
it 'removes a status' do
|
|
|
|
allow(RemovalWorker).to receive(:perform_async)
|
|
|
|
subject.call
|
|
|
|
expect(RemovalWorker).to have_received(:perform_async).with(status_ids.first)
|
2017-05-24 03:45:43 +10: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 19:10:28 +10:00
|
|
|
end
|