<commit_before>require "cases/helper"
require 'models/developer'
require 'models/project'
require 'models/company'
require 'models/topic'
require 'models/reply'
require 'models/category'
require 'models/post'
require 'models/author'
require 'models/comment'
require 'models/person'
require 'models/reader'

class HasManyAssociationsTest < ActiveRecord::TestCase
  fixtures :accounts, :categories, :companies, :developers, :projects,
           :developers_projects, :topics, :authors, :comments, :author_addresses,
           :people, :posts

  def setup
    Client.destroyed_client_ids.clear
  end

  def force_signal37_to_load_all_clients_of_firm
    companies(:first_firm).clients_of_firm.each {|f| }
  end

  def test_counting_with_counter_sql
    assert_equal 2, Firm.find(:first).clients.count
  end

  def test_counting
    assert_equal 2, Firm.find(:first).plain_clients.count
  end

  def test_counting_with_empty_hash_conditions
    assert_equal 2, Firm.find(:first).plain_clients.count(:conditions => {})
  end

  def test_counting_with_single_conditions
    assert_equal 2, Firm.find(:first).plain_clients.count(:conditions => '1=1')
  end

  def test_counting_with_single_hash
    assert_equal 2, Firm.find(:first).plain_clients.count(:conditions => '1=1')
  end

  def test_counting_with_column_name_and_hash
    assert_equal 2, Firm.find(:first).plain_clients.count(:all, :conditions => '1=1')
  end

  def test_finding
    assert_equal 2, Firm.find(:first).clients.length
  end

  def test_find_with_blank_conditions
    [[], {}, nil, ""].each do |blank|
      assert_equal 2, Firm.find(:first).clients.find(:all, :conditions => blank).size<commit_msg>Added some has_many tests<commit_after>require "cases/helper"
require 'models/developer'
require 'models/project'
require 'models/company'
require 'models/topic'
require 'models/reply'
require 'models/category'
require 'models/post'
require 'models/author'
require 'models/comment'
require 'models/person'
require 'models/reader'

class HasManyAssociationsTest < ActiveRecord::TestCase
  fixtures :accounts, :categories, :companies, :developers, :projects,
           :developers_projects, :topics, :authors, :comments, :author_addresses,
           :people, :posts

  def setup
    Client.destroyed_client_ids.clear
  end

  def force_signal37_to_load_all_clients_of_firm
    companies(:first_firm).clients_of_firm.each {|f| }
  end

  def test_counting_with_counter_sql
    assert_equal 2, Firm.find(:first).clients.count
  end

  def test_counting
    assert_equal 2, Firm.find(:first).plain_clients.count
  end

  def test_counting_with_empty_hash_conditions
    assert_equal 2, Firm.find(:first).plain_clients.count(:conditions => {})
  end

  def test_counting_with_single_conditions
    assert_equal 1, Firm.find(:first).plain_clients.count(:conditions => 'name="Microsoft"')
  end

  def test_counting_with_single_hash
    assert_equal 1, Firm.find(:first).plain_clients.count(:conditions => {:name => "Microsoft"})
  end

  def test_counting_with_column_name_and_hash
    assert_equal 2, Firm.find(:first).plain_clients.count(:name)
  end

  def test_finding
    assert_equal 2, Firm.find(:first).clients.length
  end

  def test_find_with_blank_conditions
    [[], {}, nil, ""].each do |blank|
      assert_equal 2, Firm.find(:first).clients.find(:all, :conditions => blank).size
{'fraction_non_alphanumeric': 0.1111111111111111, 'fraction_numerical': 0.0077450104259755735, 'mean_word_length': 5.050450450450451, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '5563499', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1077, 'n_words': 213}