Updated

app/controllers/admin / moderation_controller.rb

A
32 lines of codes
5 methods
3.8 complexity/method
10 churn
18.82 complexity
0 duplications
class Admin::ModerationController < Admin::AdminController
  1. Admin::ModerationController assumes too much for instance variable '@petition'
  2. Admin::ModerationController has no descriptive comment
before_action :fetch_petition def update if @petition.moderate(moderation_params) send_notifications redirect_to [:admin, @petition] else render 'admin/petitions/show' end end private def fetch_petition @petition = Petition.todo_list.find(params[:petition_id]) end def moderation_params params.require(:petition).permit(:moderation, 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