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