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