From dbe9f33fdc9a995b07ff3b1dcd93ad02cd336649 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Mon, 10 Apr 2017 15:27:03 -0400 Subject: 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 --- app/controllers/admin/domain_blocks_controller.rb | 42 +++++++++++------------ 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'app/controllers/admin/domain_blocks_controller.rb') diff --git a/app/controllers/admin/domain_blocks_controller.rb b/app/controllers/admin/domain_blocks_controller.rb index 1f4432847..58f1efa5b 100644 --- a/app/controllers/admin/domain_blocks_controller.rb +++ b/app/controllers/admin/domain_blocks_controller.rb @@ -1,32 +1,30 @@ # frozen_string_literal: true -class Admin::DomainBlocksController < ApplicationController - before_action :require_admin! - - layout 'admin' - - def index - @blocks = DomainBlock.paginate(page: params[:page], per_page: 40) - end +module Admin + class DomainBlocksController < BaseController + def index + @blocks = DomainBlock.paginate(page: params[:page], per_page: 40) + end - def new - @domain_block = DomainBlock.new - end + def new + @domain_block = DomainBlock.new + end - def create - @domain_block = DomainBlock.new(resource_params) + def create + @domain_block = DomainBlock.new(resource_params) - if @domain_block.save - DomainBlockWorker.perform_async(@domain_block.id) - redirect_to admin_domain_blocks_path, notice: 'Domain block is now being processed' - else - render action: :new + if @domain_block.save + DomainBlockWorker.perform_async(@domain_block.id) + redirect_to admin_domain_blocks_path, notice: 'Domain block is now being processed' + else + render action: :new + end end - end - private + private - def resource_params - params.require(:domain_block).permit(:domain, :severity) + def resource_params + params.require(:domain_block).permit(:domain, :severity) + end end end -- cgit