about summary refs log tree commit diff
path: root/app/controllers/admin/reports_controller.rb
diff options
context:
space:
mode:
authorMatt Jankowski <mjankowski@thoughtbot.com>2017-04-10 15:27:03 -0400
committerEugen <eugen@zeonfederated.com>2017-04-10 21:27:03 +0200
commitdbe9f33fdc9a995b07ff3b1dcd93ad02cd336649 (patch)
treed89768083aba71c27789dfb08651ef27811954cf /app/controllers/admin/reports_controller.rb
parent1be6aa0c7fdac51e81ff7ee0c2b9184ed29ca3de (diff)
Admin base controller (#1465)
* Add Admin::BaseController to wrap admin area

Extracts the setting of the `admin` layout and verifying that users are admins
to a common base class for the admin/ controllers.

* Add basic coverage for admin/reports and admin/settings controllers
Diffstat (limited to 'app/controllers/admin/reports_controller.rb')
-rw-r--r--app/controllers/admin/reports_controller.rb81
1 files changed, 40 insertions, 41 deletions
diff --git a/app/controllers/admin/reports_controller.rb b/app/controllers/admin/reports_controller.rb
index 2b3b1809f..5a37d8e6e 100644
--- a/app/controllers/admin/reports_controller.rb
+++ b/app/controllers/admin/reports_controller.rb
@@ -1,45 +1,44 @@
 # frozen_string_literal: true
 
-class Admin::ReportsController < ApplicationController
-  before_action :require_admin!
-  before_action :set_report, except: [:index]
-
-  layout 'admin'
-
-  def index
-    @reports = Report.includes(:account, :target_account).order('id desc').paginate(page: params[:page], per_page: 40)
-    @reports = params[:action_taken].present? ? @reports.resolved : @reports.unresolved
-  end
-
-  def show
-    @statuses = Status.where(id: @report.status_ids)
-  end
-
-  def resolve
-    @report.update(action_taken: true, action_taken_by_account_id: current_account.id)
-    redirect_to admin_report_path(@report)
-  end
-
-  def suspend
-    Admin::SuspensionWorker.perform_async(@report.target_account.id)
-    Report.unresolved.where(target_account: @report.target_account).update_all(action_taken: true, action_taken_by_account_id: current_account.id)
-    redirect_to admin_report_path(@report)
-  end
-
-  def silence
-    @report.target_account.update(silenced: true)
-    Report.unresolved.where(target_account: @report.target_account).update_all(action_taken: true, action_taken_by_account_id: current_account.id)
-    redirect_to admin_report_path(@report)
-  end
-
-  def remove
-    RemovalWorker.perform_async(params[:status_id])
-    redirect_to admin_report_path(@report)
-  end
-
-  private
-
-  def set_report
-    @report = Report.find(params[:id])
+module Admin
+  class ReportsController < BaseController
+    before_action :set_report, except: [:index]
+
+    def index
+      @reports = Report.includes(:account, :target_account).order('id desc').paginate(page: params[:page], per_page: 40)
+      @reports = params[:action_taken].present? ? @reports.resolved : @reports.unresolved
+    end
+
+    def show
+      @statuses = Status.where(id: @report.status_ids)
+    end
+
+    def resolve
+      @report.update(action_taken: true, action_taken_by_account_id: current_account.id)
+      redirect_to admin_report_path(@report)
+    end
+
+    def suspend
+      Admin::SuspensionWorker.perform_async(@report.target_account.id)
+      Report.unresolved.where(target_account: @report.target_account).update_all(action_taken: true, action_taken_by_account_id: current_account.id)
+      redirect_to admin_report_path(@report)
+    end
+
+    def silence
+      @report.target_account.update(silenced: true)
+      Report.unresolved.where(target_account: @report.target_account).update_all(action_taken: true, action_taken_by_account_id: current_account.id)
+      redirect_to admin_report_path(@report)
+    end
+
+    def remove
+      RemovalWorker.perform_async(params[:status_id])
+      redirect_to admin_report_path(@report)
+    end
+
+    private
+
+    def set_report
+      @report = Report.find(params[:id])
+    end
   end
 end