Updated

app/controllers/admin / schedule_debate_controller.rb

B
36 lines of codes
5 methods
3.7 complexity/method
9 churn
18.44 complexity
28 duplications
class Admin::ScheduleDebateController < Admin::AdminController
  1. Admin::ScheduleDebateController assumes too much for instance variable '@petition'
  2. Admin::ScheduleDebateController has no descriptive comment
before_action :fetch_petition def show render 'admin/petitions/show' end def update
  1. Similar code found in 3 nodes Locations: 0 1 2
if @petition.update_attributes(params_for_update) if send_email_to_petitioners? EmailDebateScheduledJob.run_later_tonight(petition: @petition) message = :email_sent_overnight else message = :debate_date_updated end redirect_to [:admin, @petition], notice: message else render 'admin/petitions/show' end end private def fetch_petition @petition = Petition.find(params[:petition_id]) end def params_for_update params.require(:petition).permit(:scheduled_debate_date) end def send_email_to_petitioners? params.key?(:save_and_email) end end