<commit_before>class SupportedPermission < ActiveRecord::Base
  belongs_to :application, class_name: 'Doorkeeper::Application'

  validates_presence_of :name
  validate :freeze_signin_permission_name, if: :name_changed?

  attr_accessible :application_id, :name, :delegatable

private

  def freeze_signin_permission_name
    if %w(signin Signin).include?(name_change.first)
      errors.add(:name, "of permission #{name_change.first} can't be changed")
    end
  end

end
<commit_msg>More readable validation<commit_after>class SupportedPermission < ActiveRecord::Base
  belongs_to :application, class_name: 'Doorkeeper::Application'

  validates_presence_of :name
  validate :signin_permission_name_not_changed

  attr_accessible :application_id, :name, :delegatable

private

  def signin_permission_name_not_changed
    return if new_record? || !name_changed?

    if name_change.first.downcase == 'signin'
      errors.add(:name, "of permission #{name_change.first} can't be changed")
    end
  end

end

{'fraction_non_alphanumeric': 0.08622398414271557, 'fraction_numerical': 0.0, 'mean_word_length': 5.733333333333333, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1988798', 'n_tokens_mistral': 321, 'n_tokens_neox': 313, 'n_words': 70}