Updated

app/controllers/admin/archived / schedule_debate_controller.rb

B
36 lines of codes
5 methods
3.9 complexity/method
1 churn
19.72 complexity
28 duplications
class Admin::Archived::ScheduleDebateController < Admin::AdminController
  1. Admin::Archived::ScheduleDebateController assumes too much for instance variable '@petition'
  2. Admin::Archived::ScheduleDebateController has no descriptive comment
before_action :fetch_petition def show render 'admin/archived/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? ::Archived::EmailDebateScheduledJob.run_later_tonight(petition: @petition) message = :email_sent_overnight else message = :debate_date_updated end redirect_to admin_archived_petition_url(@petition), notice: message else render 'admin/archived/petitions/show' end end private def fetch_petition @petition = ::Archived::Petition.find(params[:petition_id]) end def params_for_update params.require(:archived_petition).permit(:scheduled_debate_date) end def send_email_to_petitioners? params.key?(:save_and_email) end end