aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2017-06-02 01:37:33 +0930
committerGitHub <noreply@github.com>2017-06-02 01:37:33 +0930
commit0c2abaa3e7bc2ea8e790fe4c1a255443ebab4c42 (patch)
treeb97d9248c09ea9ad44aa6787151f34e07057f206
parent051e78c57a43c2bd1a35b483dcc0e46c77b2f6ff (diff)
parente28e37c0149834af4d620f5d2063ce3c1e4b7921 (diff)
downloadrails-0c2abaa3e7bc2ea8e790fe4c1a255443ebab4c42.tar.gz
rails-0c2abaa3e7bc2ea8e790fe4c1a255443ebab4c42.tar.bz2
rails-0c2abaa3e7bc2ea8e790fe4c1a255443ebab4c42.zip
Merge pull request #29308 from koic/correct_a_has_many_association_test
Correct a has_many association test
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb2
-rw-r--r--activerecord/test/models/company.rb1
2 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index a794eba691..590d3642bd 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -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
diff --git a/activerecord/test/models/company.rb b/activerecord/test/models/company.rb
index d269a95e8c..c6a5bf1c92 100644
--- a/activerecord/test/models/company.rb
+++ b/activerecord/test/models/company.rb
@@ -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