<commit_before>require File.dirname(__FILE__) + '/../test_helper'
require 'activerecord_rules'

# Simple model to use while testing ActiveRecord requirement types.
class Dog < ActiveRecord::Base ; end

class ActiveRecordRulesTest < Test::Unit::TestCase

  include ValidateRequest
  
  # Preserve class variables, so that we can mess with them, and they'll be
  # restored for any other tests.
  def setup
    @old_ignore_columns = ActiveRecordRules.ignore_columns
  end
  
  def teardown
    ActiveRecordRules.ignore_columns = @old_ignore_columns
  end

  def test_ignore_columns
    old_value = ActiveRecordRules.ignore_columns
    assert_equal old_value, ActiveRecordRules.ignore_columns
    new_value = %( a b c )
    assert_not_equal old_value, new_value
    ActiveRecordRules.ignore_columns = new_value
    assert_equal new_value, ActiveRecordRules.ignore_columns
    ActiveRecordRules.ignore_columns << "d"
    new_value << "d"
    assert_equal new_value, ActiveRecordRules.ignore_columns
  end
    
  def test_no_models<commit_msg>Fix problem (unnoticed) where we weren't really saving the hash from modification since we weren't dup-ing it.<commit_after>require File.dirname(__FILE__) + '/../test_helper'
require 'activerecord_rules'

# Simple model to use while testing ActiveRecord requirement types.
class Dog < ActiveRecord::Base ; end

class ActiveRecordRulesTest < Test::Unit::TestCase

  include ValidateRequest
  
  # Preserve class variables, so that we can mess with them, and they'll be
  # restored for any other tests.
  def setup
    @old_ignore_columns = ActiveRecordRules.ignore_columns.dup
  end
  
  def teardown
    ActiveRecordRules.ignore_columns = @old_ignore_columns
  end

  def test_ignore_columns
    old_value = ActiveRecordRules.ignore_columns
    assert_equal old_value, ActiveRecordRules.ignore_columns
    new_value = %( a b c )
    assert_not_equal old_value, new_value
    ActiveRecordRules.ignore_columns = new_value
    assert_equal new_value, ActiveRecordRules.ignore_columns
    ActiveRecordRules.ignore_columns << "d"
    new_value << "d"
    assert_equal new_value, ActiveRecordRules.ignore_columns
  end
    
  def test_no_models
{'fraction_non_alphanumeric': 0.060174552135966924, 'fraction_numerical': 0.0, 'mean_word_length': 4.472361809045226, 'pattern_counts': {'":': 0, '<': 15, '<?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': '4537584', 'n_tokens_mistral': 631, 'n_tokens_neox': 619, 'n_words': 175}