<commit_before>class GroupMembershipRequest < ActiveRecord::Base
  ALLOWED_STATUS = %w(pending confirmed rejected cancelled)

  belongs_to :group
  belongs_to :user
  belongs_to :actioned_by, class_name: "User"

  validates_associated :user
  validates_associated :group
  validates :status, inclusion: {in: ALLOWED_STATUS}<commit_msg>Convert to state machine<commit_after>class GroupMembershipRequest < ActiveRecord::Base
  attr_protected :state_event

  belongs_to :group
  belongs_to :user
  belongs_to :actioned_by, class_name: "User"

  validates :user, presence: true
  validates :group, presence: true

  state_machine :status, :initial => :pending do
    state :pending, :cancelled

    state :confirmed, :rejected do
      validates :actioned_by, presence: true
    end

    event :confirm do
      transition :pending => :confirmed
    end

    event :reject do
      transition :pending => :rejected
    end

    event :cancel do
      transition :pending => :cancelled
    end
  end

  def initalize
    super
  end
{'fraction_non_alphanumeric': 0.0730282375851996, 'fraction_numerical': 0.0, 'mean_word_length': 3.9902912621359223, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4108900', 'n_tokens_mistral': 316, 'n_tokens_neox': 306, 'n_words': 91}