0
@@ -384,7 +384,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
0
company = companies(:first_firm)
0
new_client = assert_no_queries { company.clients_of_firm.build("name" => "Another Client") }
0
assert !company.clients_of_firm.loaded?
0
assert_equal "Another Client", new_client.name
0
assert new_client.new_record?
0
assert_equal new_client, company.clients_of_firm.last
0
@@ -416,7 +416,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
0
company = companies(:first_firm)
0
new_clients = assert_no_queries { company.clients_of_firm.build([{"name" => "Another Client"}, {"name" => "Another Client II"}]) }
0
assert_equal 2, new_clients.size
0
company.name += '-changed'
0
assert_queries(3) { assert company.save }
0
@@ -655,10 +655,10 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
0
def test_creation_respects_hash_condition
0
ms_client = companies(:first_firm).clients_like_ms_with_hash_conditions.build
0
assert_equal 'Microsoft', ms_client.name
0
another_ms_client = companies(:first_firm).clients_like_ms_with_hash_conditions.create
0
assert !another_ms_client.new_record?
0
@@ -830,6 +830,22 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
0
assert_equal [companies(:first_client).id, companies(:second_client).id], companies(:first_firm).client_ids
0
+ def test_get_ids_for_loaded_associations
0
+ company = companies(:first_firm)
0
+ def test_get_ids_for_unloaded_associations_does_not_load_them
0
+ company = companies(:first_firm)
0
+ assert !company.clients.loaded?
0
+ assert_equal [companies(:first_client).id, companies(:second_client).id], company.client_ids
0
+ assert !company.clients.loaded?
0
firm = Firm.new("name" => "Apple")
0
firm.client_ids = [companies(:first_client).id, companies(:second_client).id]
0
@@ -900,7 +916,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
0
assert_equal 4, authors(:david).limited_comments.find(:all, :conditions => "comments.type = 'SpecialComment'", :limit => 9_000).length
0
assert_equal 4, authors(:david).limited_comments.find_all_by_type('SpecialComment', :limit => 9_000).length
0
def test_find_all_include_over_the_same_table_for_through
0
assert_equal 2, people(:michael).posts.find(:all, :include => :people).length
0
@@ -937,13 +953,13 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
0
def test_include_loads_collection_if_target_uses_finder_sql
0
firm = companies(:first_firm)
0
client = firm.clients_using_sql.first
0
assert ! firm.clients_using_sql.loaded?
0
assert firm.clients_using_sql.include?(client)
0
assert firm.clients_using_sql.loaded?
0
def test_include_returns_false_for_non_matching_record_to_verify_scoping
0
firm = companies(:first_firm)