mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Correct a has_many association test
This commit is contained in:
parent
908b136cf2
commit
e28e37c014
2 changed files with 2 additions and 1 deletions
|
@ -1355,7 +1355,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
|
|||
Client.create(client_of: firm.id, name: "SmallTime Inc.")
|
||||
# only one of two clients is included in the association due to the :conditions key
|
||||
assert_equal 2, Client.where(client_of: firm.id).size
|
||||
assert_equal 1, firm.dependent_sanitized_conditional_clients_of_firm.size
|
||||
assert_equal 1, firm.dependent_hash_conditional_clients_of_firm.size
|
||||
firm.destroy
|
||||
# only the correctly associated client should have been deleted
|
||||
assert_equal 1, Client.where(client_of: firm.id).size
|
||||
|
|
|
@ -175,6 +175,7 @@ end
|
|||
class ExclusivelyDependentFirm < Company
|
||||
has_one :account, foreign_key: "firm_id", dependent: :delete
|
||||
has_many :dependent_sanitized_conditional_clients_of_firm, -> { order("id").where("name = 'BigShot Inc.'") }, foreign_key: "client_of", class_name: "Client", dependent: :delete_all
|
||||
has_many :dependent_hash_conditional_clients_of_firm, -> { order("id").where(name: "BigShot Inc.") }, foreign_key: "client_of", class_name: "Client", dependent: :delete_all
|
||||
has_many :dependent_conditional_clients_of_firm, -> { order("id").where("name = ?", "BigShot Inc.") }, foreign_key: "client_of", class_name: "Client", dependent: :delete_all
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue