mirror of
https://github.com/mastodon/mastodon.git
synced 2025-02-06 06:55:04 +00:00
Convert admin/reports
spec controller->system (#33789)
Some checks are pending
Bundler Audit / security (push) Waiting to run
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Haml Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / Libvips tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.2) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Some checks are pending
Bundler Audit / security (push) Waiting to run
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Haml Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / Libvips tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.2) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
This commit is contained in:
parent
91e4a09f24
commit
77587913ce
|
@ -1,125 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::ReportsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'returns http success with no filters' do
|
||||
specified = Fabricate(:report, action_taken_at: nil, comment: 'First report')
|
||||
other = Fabricate(:report, action_taken_at: Time.now.utc, comment: 'Second report')
|
||||
|
||||
get :index
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.body)
|
||||
.to include(specified.comment)
|
||||
.and not_include(other.comment)
|
||||
end
|
||||
|
||||
it 'returns http success with resolved filter' do
|
||||
specified = Fabricate(:report, action_taken_at: Time.now.utc, comment: 'First report')
|
||||
other = Fabricate(:report, action_taken_at: nil, comment: 'Second report')
|
||||
|
||||
get :index, params: { resolved: '1' }
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.body)
|
||||
.to include(specified.comment)
|
||||
.and not_include(other.comment)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'renders report' do
|
||||
report = Fabricate(:report, comment: 'A big problem')
|
||||
|
||||
get :show, params: { id: report }
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.body)
|
||||
.to include(report.comment)
|
||||
end
|
||||
|
||||
describe 'account moderation notes' do
|
||||
let(:report) { Fabricate(:report) }
|
||||
|
||||
it 'includes moderation notes' do
|
||||
note1 = Fabricate(:report_note, report: report)
|
||||
note2 = Fabricate(:report_note, report: report)
|
||||
|
||||
get :show, params: { id: report }
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
report_notes = assigns(:report_notes).to_a
|
||||
|
||||
expect(report_notes.size).to be 2
|
||||
expect(report_notes).to eq [note1, note2]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
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 be true
|
||||
expect(last_action_log.target).to eq(report)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #reopen' do
|
||||
it 'reopens the report' do
|
||||
report = Fabricate(:report, action_taken_at: 3.days.ago)
|
||||
|
||||
put :reopen, params: { id: report }
|
||||
expect(response).to redirect_to(admin_report_path(report))
|
||||
report.reload
|
||||
expect(report.action_taken_by_account).to be_nil
|
||||
expect(report.action_taken?).to be false
|
||||
expect(last_action_log.target).to eq(report)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #assign_to_self' do
|
||||
it 'reopens the report' do
|
||||
report = Fabricate(:report)
|
||||
|
||||
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
|
||||
expect(last_action_log.target).to eq(report)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #unassign' do
|
||||
it 'reopens the report' do
|
||||
report = Fabricate(:report, assigned_account_id: Account.last.id)
|
||||
|
||||
put :unassign, params: { id: report }
|
||||
expect(response).to redirect_to(admin_report_path(report))
|
||||
report.reload
|
||||
expect(report.assigned_account).to be_nil
|
||||
expect(last_action_log.target).to eq(report)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def last_action_log
|
||||
Admin::ActionLog.last
|
||||
end
|
||||
end
|
112
spec/system/admin/reports_spec.rb
Normal file
112
spec/system/admin/reports_spec.rb
Normal file
|
@ -0,0 +1,112 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin Reports' do
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
describe 'Viewing existing reports' do
|
||||
let!(:unresolved_report) { Fabricate(:report, action_taken_at: nil, comment: 'First report') }
|
||||
let!(:resolved_report) { Fabricate(:report, action_taken_at: Time.now.utc, comment: 'Second report') }
|
||||
let!(:report_note) { Fabricate :report_note, report: resolved_report, content: 'Note about resolved report' }
|
||||
|
||||
it 'Shows basic report details' do
|
||||
visit admin_reports_path
|
||||
|
||||
expect(page)
|
||||
.to have_content(unresolved_report.comment)
|
||||
.and have_no_content(resolved_report.comment)
|
||||
|
||||
click_on I18n.t('admin.reports.resolved')
|
||||
expect(page)
|
||||
.to have_content(resolved_report.comment)
|
||||
.and have_no_content(unresolved_report.comment)
|
||||
|
||||
click_on resolved_report.comment
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.reports.report', id: resolved_report.id))
|
||||
.and have_content(resolved_report.comment)
|
||||
.and have_content(report_note.content)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Resolving reports' do
|
||||
let!(:report) { Fabricate :report }
|
||||
|
||||
it 'resolves an open report' do
|
||||
visit admin_report_path(report)
|
||||
within '.content__heading__actions' do
|
||||
click_on I18n.t('admin.reports.mark_as_resolved')
|
||||
end
|
||||
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.reports.title'))
|
||||
.and have_content(I18n.t('admin.reports.resolved_msg'))
|
||||
|
||||
report.reload
|
||||
expect(report.action_taken_by_account)
|
||||
.to eq user.account
|
||||
expect(report)
|
||||
.to be_action_taken
|
||||
expect(last_action_log.target)
|
||||
.to eq(report)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Reopening reports' do
|
||||
let!(:report) { Fabricate :report, action_taken_at: 3.days.ago }
|
||||
|
||||
it 'reopens a resolved report' do
|
||||
visit admin_report_path(report)
|
||||
within '.content__heading__actions' do
|
||||
click_on I18n.t('admin.reports.mark_as_unresolved')
|
||||
end
|
||||
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.reports.report', id: report.id))
|
||||
|
||||
report.reload
|
||||
expect(report.action_taken_by_account)
|
||||
.to be_nil
|
||||
expect(report)
|
||||
.to_not be_action_taken
|
||||
expect(last_action_log.target)
|
||||
.to eq(report)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Assigning reports' do
|
||||
let!(:report) { Fabricate :report }
|
||||
|
||||
it 'assigns report to user and then unassigns' do
|
||||
visit admin_report_path(report)
|
||||
|
||||
click_on I18n.t('admin.reports.assign_to_self')
|
||||
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.reports.report', id: report.id))
|
||||
report.reload
|
||||
expect(report.assigned_account)
|
||||
.to eq user.account
|
||||
expect(last_action_log.target)
|
||||
.to eq(report)
|
||||
|
||||
click_on I18n.t('admin.reports.unassign')
|
||||
expect(page)
|
||||
.to have_title(I18n.t('admin.reports.report', id: report.id))
|
||||
report.reload
|
||||
expect(report.assigned_account)
|
||||
.to be_nil
|
||||
expect(last_action_log.target)
|
||||
.to eq(report)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def last_action_log
|
||||
Admin::ActionLog.last
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user