2017-07-18 15:38:22 +01:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe Admin::StatusesController do
|
|
|
|
render_views
|
|
|
|
|
|
|
|
let(:user) { Fabricate(:user, admin: true) }
|
|
|
|
let(:account) { Fabricate(:account) }
|
|
|
|
let!(:status) { Fabricate(:status, account: account) }
|
|
|
|
let(:media_attached_status) { Fabricate(:status, account: account, sensitive: !sensitive) }
|
|
|
|
let!(:media_attachment) { Fabricate(:media_attachment, account: account, status: media_attached_status) }
|
2021-11-26 21:12:27 +00:00
|
|
|
let(:last_media_attached_status) { Fabricate(:status, account: account, sensitive: !sensitive) }
|
|
|
|
let!(:last_media_attachment) { Fabricate(:media_attachment, account: account, status: last_media_attached_status) }
|
|
|
|
let!(:last_status) { Fabricate(:status, account: account) }
|
2017-07-18 15:38:22 +01:00
|
|
|
let(:sensitive) { true }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in user, scope: :user
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET #index' do
|
2022-01-17 08:41:33 +00:00
|
|
|
context do
|
|
|
|
before do
|
|
|
|
get :index, params: { account_id: account.id }
|
|
|
|
end
|
2017-07-18 15:38:22 +01:00
|
|
|
|
2022-01-17 08:41:33 +00:00
|
|
|
it 'returns http success' do
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
2017-07-18 15:38:22 +01:00
|
|
|
end
|
|
|
|
|
2022-01-17 08:41:33 +00:00
|
|
|
context 'filtering by media' do
|
|
|
|
before do
|
|
|
|
get :index, params: { account_id: account.id, media: '1' }
|
|
|
|
end
|
2017-07-18 15:38:22 +01:00
|
|
|
|
2022-01-17 08:41:33 +00:00
|
|
|
it 'returns http success' do
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
2017-07-18 15:38:22 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-01-17 08:41:33 +00:00
|
|
|
describe 'POST #batch' do
|
|
|
|
before do
|
|
|
|
post :batch, params: { :account_id => account.id, action => '', :admin_status_batch_action => { status_ids: status_ids } }
|
2017-07-18 15:38:22 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
let(:status_ids) { [media_attached_status.id] }
|
|
|
|
|
2022-01-17 08:41:33 +00:00
|
|
|
context 'when action is report' do
|
|
|
|
let(:action) { 'report' }
|
2017-07-18 15:38:22 +01:00
|
|
|
|
2022-01-17 08:41:33 +00:00
|
|
|
it 'creates a report' do
|
|
|
|
report = Report.last
|
|
|
|
expect(report.target_account_id).to eq account.id
|
|
|
|
expect(report.status_ids).to eq status_ids
|
2017-07-18 15:38:22 +01:00
|
|
|
end
|
|
|
|
|
2022-01-17 08:41:33 +00:00
|
|
|
it 'redirects to report page' do
|
|
|
|
expect(response).to redirect_to(admin_report_path(Report.last.id))
|
2017-07-18 15:38:22 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|