<commit_before>require 'test/helper'

class TypusUserTest < ActiveSupport::TestCase

  def setup
    @data = { :first_name => '', 
              :last_name => '', 
              :email => '<EMAIL>', 
              :password => '<PASSWORD>', 
              :password_confirmation => '<PASSWORD>', 
              :role => Typus::Configuration.options[:root] }
    @typus_user = TypusUser.new(@data)
  end

  def test_should_verify_typus_user_attributes
    %w( first_name last_name email role salt crypted_password ).each do |attribute|
      assert TypusUser.instance_methods.include?(attribute)
    end
  end

  def test_should_verify_email_format
    @typus_user.email = 'admin'
    assert @typus_user.invalid?
    assert @typus_user.errors.invalid?(:email)
  end

  def test_should_verify_email_is_not_valid
    email = <<-RAW
<EMAIL>
<script>location.href="http://spammersite.com"</script>
    RAW
    @typus_user.email = email
    assert @typus_user.invalid?
    assert @typus_user.errors.invalid?(:email)
  end

  def test_should_verify_emails_are_downcase
    email = '<EMAIL>'
    @typus_user.email = email
    assert @typus_user.invalid?
    assert @typus_user.errors.invalid?(:email)<commit_msg>Test instance methods are defined.<commit_after>require 'test/helper'

class TypusUserTest < ActiveSupport::TestCase

  def setup
    @data = { :first_name => '', 
              :last_name => '', 
              :email => '<EMAIL>', 
              :password => '<PASSWORD>', 
              :password_confirmation => '<PASSWORD>', 
              :role => Typus::Configuration.options[:root] }
    @typus_user = TypusUser.new(@data)
  end

  def test_should_verify_typus_user_attributes
    %w( first_name last_name email role salt crypted_password ).each do |attribute|
      assert TypusUser.instance_methods.include?(attribute)
    end
  end

  def test_should_verify_definition_on_instance_methods
    %w( is_root? authenticated? ).each do |instance_method|
      assert TypusUser.instance_methods.include?(instance_method)
    end
  end

  def test_should_verify_email_format
    @typus_user.email = 'admin'
    assert @typus_user.invalid?
    assert @typus_user.errors.invalid?(:email)
  end

  def test_should_verify_email_is_not_valid
    email = <<-RAW
<EMAIL>
<script>location.href="http://spammersite.com"</script>
    RAW
    @typus_user.email = email
    assert @typus_user.invalid?
    assert @typus_user.errors.invalid?(:email)
  end

  def test_should_verify_emails_are_downcase
    email = '<EMAIL>'
    @typus_user.email = email
    assert @typus_user.invalid?
    assert @typus_user.errors.invalid?(:email)
{'fraction_non_alphanumeric': 0.11195734958111196, 'fraction_numerical': 0.0, 'mean_word_length': 3.3783333333333334, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 29, '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': '7433871', 'n_tokens_mistral': 856, 'n_tokens_neox': 833, 'n_words': 155}