Updated

app/controllers/admin / take_down_controller.rb

A
36 lines of codes
6 methods
3.3 complexity/method
8 churn
20.03 complexity
0 duplications
class Admin::TakeDownController < Admin::AdminController
  1. Admin::TakeDownController assumes too much for instance variable '@petition'
  2. Admin::TakeDownController has no descriptive comment
before_action :fetch_petition def show render 'admin/petitions/show' end def update if @petition.reject(rejection_params[:rejection]) send_notifications redirect_to [:admin, @petition] else render 'admin/petitions/show' end end private def fetch_petition @petition = Petition.find(params[:petition_id]) end def rejection_params params.require(:petition).permit(rejection: [:code, :details]) end def send_notifications if send_email_to_creator_and_sponsors? NotifyEveryoneOfModerationDecisionJob.perform_later(@petition) end end def send_email_to_creator_and_sponsors? params.key?(:save_and_email) end end