2017-04-11 04:27:03 +09:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-04-14 18:10:28 +09:00
|
|
|
describe Admin::ReportsController do
|
2017-04-28 08:21:38 +09:00
|
|
|
render_views
|
|
|
|
|
2017-04-14 18:10:28 +09:00
|
|
|
let(:user) { Fabricate(:user, admin: true) }
|
|
|
|
before do
|
|
|
|
sign_in user, scope: :user
|
|
|
|
end
|
|
|
|
|
2017-04-11 04:27:03 +09:00
|
|
|
describe 'GET #index' do
|
2017-04-14 18:10:28 +09:00
|
|
|
it 'returns http success with no filters' do
|
2017-05-30 01:12:34 +09:00
|
|
|
specified = Fabricate(:report, action_taken: false)
|
|
|
|
Fabricate(:report, action_taken: true)
|
|
|
|
|
2017-04-14 18:10:28 +09:00
|
|
|
get :index
|
|
|
|
|
2017-05-30 01:12:34 +09:00
|
|
|
reports = assigns(:reports).to_a
|
|
|
|
expect(reports.size).to eq 1
|
|
|
|
expect(reports[0]).to eq specified
|
2018-04-22 04:35:07 +09:00
|
|
|
expect(response).to have_http_status(200)
|
2017-04-11 04:27:03 +09:00
|
|
|
end
|
|
|
|
|
2017-04-14 18:10:28 +09:00
|
|
|
it 'returns http success with resolved filter' do
|
2017-05-30 01:12:34 +09:00
|
|
|
specified = Fabricate(:report, action_taken: true)
|
|
|
|
Fabricate(:report, action_taken: false)
|
|
|
|
|
2017-04-14 18:10:28 +09:00
|
|
|
get :index, params: { resolved: 1 }
|
|
|
|
|
2017-05-30 01:12:34 +09:00
|
|
|
reports = assigns(:reports).to_a
|
|
|
|
expect(reports.size).to eq 1
|
|
|
|
expect(reports[0]).to eq specified
|
|
|
|
|
2018-04-22 04:35:07 +09:00
|
|
|
expect(response).to have_http_status(200)
|
2017-04-14 18:10:28 +09:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET #show' do
|
2017-05-30 01:12:34 +09:00
|
|
|
it 'renders report' do
|
2017-04-14 18:10:28 +09:00
|
|
|
report = Fabricate(:report)
|
|
|
|
|
|
|
|
get :show, params: { id: report }
|
2017-05-30 01:12:34 +09:00
|
|
|
|
|
|
|
expect(assigns(:report)).to eq report
|
2018-04-22 04:35:07 +09:00
|
|
|
expect(response).to have_http_status(200)
|
2017-04-11 04:27:03 +09:00
|
|
|
end
|
|
|
|
end
|
2017-04-14 18:10:28 +09:00
|
|
|
|
2020-03-21 11:08:09 +09:00
|
|
|
describe 'POST #resolve' do
|
|
|
|
it 'resolves the report' do
|
|
|
|
report = Fabricate(:report)
|
|
|
|
|
|
|
|
put :resolve, params: { id: report }
|
|
|
|
expect(response).to redirect_to(admin_reports_path)
|
|
|
|
report.reload
|
|
|
|
expect(report.action_taken_by_account).to eq user.account
|
|
|
|
expect(report.action_taken).to eq true
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sets trust level when the report is an antispam one' do
|
|
|
|
report = Fabricate(:report, account: Account.representative)
|
|
|
|
|
|
|
|
put :resolve, params: { id: report }
|
|
|
|
report.reload
|
|
|
|
expect(report.target_account.trust_level).to eq Account::TRUST_LEVELS[:trusted]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-23 04:02:09 +09:00
|
|
|
describe 'POST #reopen' do
|
|
|
|
it 'reopens the report' do
|
|
|
|
report = Fabricate(:report)
|
2018-04-03 05:04:14 +09:00
|
|
|
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-23 04:02:09 +09:00
|
|
|
put :reopen, params: { id: report }
|
|
|
|
expect(response).to redirect_to(admin_report_path(report))
|
|
|
|
report.reload
|
|
|
|
expect(report.action_taken_by_account).to eq nil
|
|
|
|
expect(report.action_taken).to eq false
|
2018-04-03 05:04:14 +09:00
|
|
|
end
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-23 04:02:09 +09:00
|
|
|
end
|
2018-04-03 05:04:14 +09:00
|
|
|
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-23 04:02:09 +09:00
|
|
|
describe 'POST #assign_to_self' do
|
|
|
|
it 'reopens the report' do
|
|
|
|
report = Fabricate(:report)
|
2018-04-03 05:04:14 +09:00
|
|
|
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-23 04:02:09 +09:00
|
|
|
put :assign_to_self, params: { id: report }
|
|
|
|
expect(response).to redirect_to(admin_report_path(report))
|
|
|
|
report.reload
|
|
|
|
expect(report.assigned_account).to eq user.account
|
2018-04-03 05:04:14 +09:00
|
|
|
end
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-23 04:02:09 +09:00
|
|
|
end
|
2018-04-03 05:04:14 +09:00
|
|
|
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-23 04:02:09 +09:00
|
|
|
describe 'POST #unassign' do
|
|
|
|
it 'reopens the report' do
|
|
|
|
report = Fabricate(:report)
|
2018-04-03 05:04:14 +09:00
|
|
|
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-23 04:02:09 +09:00
|
|
|
put :unassign, params: { id: report }
|
|
|
|
expect(response).to redirect_to(admin_report_path(report))
|
|
|
|
report.reload
|
|
|
|
expect(report.assigned_account).to eq nil
|
2018-04-03 05:04:14 +09:00
|
|
|
end
|
2017-04-14 18:10:28 +09:00
|
|
|
end
|
2017-04-11 04:27:03 +09:00
|
|
|
end
|