Updated

app/models / rejection.rb

B
26 lines of codes
2 methods
1.8 complexity/method
4 churn
3.61 complexity
18 duplications
class Rejection < ActiveRecord::Base
  1. Rejection has no descriptive comment
CODES = %w[duplicate irrelevant no-action honours fake-name foi libellous offensive] HIDDEN_CODES = %w[libellous offensive] belongs_to :petition, touch: true validates :petition, presence: true validates :code, presence: true, inclusion: { in: CODES } validates :details, length: { maximum: 4000 }, allow_blank: true after_create do
  1. Identical code found in 2 nodes Locations: 0 1
if petition.rejected_at? petition.update!(state: state_for_petition) else petition.update!(state: state_for_petition, rejected_at: Time.current) end end def hide_petition? code.in?(HIDDEN_CODES) end def state_for_petition hide_petition? ? Petition::HIDDEN_STATE : Petition::REJECTED_STATE end end