<commit_before># Copyright 2006 - <NAME>
# Released under the MIT License

module TestInjector
  
  def base_class
    @base_class ||= Module.const_get self.to_s.gsub(/Test$/, '')
  end
  
  def inject_activerecord_tests
    if base_class.ancestors.include?(ActiveRecord::Base)
      inject_association_tests if base_class.respond_to?(:reflections)
      define_acts_as_versioned_test(base_class) if base_class.include?(ActiveRecord::Acts::Versioned::ActMethods)
      define_optimistic_locking_test(base_class) if base_class.column_names.include?("lock_version")
    end
  end
  
  def inject_association_tests
    ignore_associations = [:versions, :parent, :children]
    collectible_associations = [:has_many, :has_and_belongs_to_many]
    
    base_class.reflect_on_all_associations.each do |association|
      
      # redefine base_class as an instance method
      define_method "base_class" do
        @base_class ||= Module.const_get self.class.to_s.gsub(/Test$/, '')
      end
      
      unless ignore_associations.include?(association.name)
        define_fixture_test(association)
        define_association_test(association)
      end

    end

  end
  
  def define_association_test(association)
    collectible_associations = [:has_many, :has_and_belongs_to_many]<commit_msg>Fix test for acts_as_versioned plugin<commit_after># Copyright 2006 - <NAME>
# Released under the MIT License

module TestInjector
  
  def base_class
    @base_class ||= Module.const_get self.to_s.gsub(/Test$/, '')
  end
  
  def inject_activerecord_tests
    if base_class.ancestors.include?(ActiveRecord::Base)
      inject_association_tests if base_class.respond_to?(:reflections)
      define_acts_as_versioned_test(base_class) if base_class.respond_to?("acts_as_versioned") and base_class.include?(ActiveRecord::Acts::Versioned::ActMethods)      define_optimistic_locking_test(base_class) if base_class.column_names.include?("lock_version")
    end
  end
  
  def inject_association_tests
    ignore_associations = [:versions, :parent, :children]
    collectible_associations = [:has_many, :has_and_belongs_to_many]
    
    base_class.reflect_on_all_associations.each do |association|
      
      # redefine base_class as an instance method
      define_method "base_class" do
        @base_class ||= Module.const_get self.class.to_s.gsub(/Test$/, '')
      end
      
      unless ignore_associations.include?(association.name)
        define_fixture_test(association)
        define_association_test(association)
      end

    end

  end
  
  def define_association_test(association)
    collectible_associations = [:has_many, :has_and_belongs_to_many]
{'fraction_non_alphanumeric': 0.08512241054613937, 'fraction_numerical': 0.0030131826741996233, 'mean_word_length': 4.197651663405088, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3714241', 'n_tokens_mistral': 869, 'n_tokens_neox': 858, 'n_words': 143}