]> cat aescling's git repositories - mastodon.git/blob - spec/controllers/admin/reports_controller_spec.rb
Add moderation warnings (#9519)
[mastodon.git] / spec / controllers / admin / reports_controller_spec.rb
1 require 'rails_helper'
2
3 describe Admin::ReportsController do
4 render_views
5
6 let(:user) { Fabricate(:user, admin: true) }
7 before do
8 sign_in user, scope: :user
9 end
10
11 describe 'GET #index' do
12 it 'returns http success with no filters' do
13 specified = Fabricate(:report, action_taken: false)
14 Fabricate(:report, action_taken: true)
15
16 get :index
17
18 reports = assigns(:reports).to_a
19 expect(reports.size).to eq 1
20 expect(reports[0]).to eq specified
21 expect(response).to have_http_status(200)
22 end
23
24 it 'returns http success with resolved filter' do
25 specified = Fabricate(:report, action_taken: true)
26 Fabricate(:report, action_taken: false)
27
28 get :index, params: { resolved: 1 }
29
30 reports = assigns(:reports).to_a
31 expect(reports.size).to eq 1
32 expect(reports[0]).to eq specified
33
34 expect(response).to have_http_status(200)
35 end
36 end
37
38 describe 'GET #show' do
39 it 'renders report' do
40 report = Fabricate(:report)
41
42 get :show, params: { id: report }
43
44 expect(assigns(:report)).to eq report
45 expect(response).to have_http_status(200)
46 end
47 end
48
49 describe 'POST #reopen' do
50 it 'reopens the report' do
51 report = Fabricate(:report)
52
53 put :reopen, params: { id: report }
54 expect(response).to redirect_to(admin_report_path(report))
55 report.reload
56 expect(report.action_taken_by_account).to eq nil
57 expect(report.action_taken).to eq false
58 end
59 end
60
61 describe 'POST #assign_to_self' do
62 it 'reopens the report' do
63 report = Fabricate(:report)
64
65 put :assign_to_self, params: { id: report }
66 expect(response).to redirect_to(admin_report_path(report))
67 report.reload
68 expect(report.assigned_account).to eq user.account
69 end
70 end
71
72 describe 'POST #unassign' do
73 it 'reopens the report' do
74 report = Fabricate(:report)
75
76 put :unassign, params: { id: report }
77 expect(response).to redirect_to(admin_report_path(report))
78 report.reload
79 expect(report.assigned_account).to eq nil
80 end
81 end
82 end
This page took 0.089242 seconds and 4 git commands to generate.