aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2017-01-07 17:30:34 -0500
committerGitHub <noreply@github.com>2017-01-07 17:30:34 -0500
commit11a50f48113df300f3225e4963aeb1030ec6ad35 (patch)
treea83fb72f41fea92ec9e58fb242c966b0342219dd /activerecord/test/cases
parent7b13236818ffb26e94d72885e75966efffd71659 (diff)
parentc322b7c2b1ace59921e0613151b26c8256e62a82 (diff)
downloadrails-11a50f48113df300f3225e4963aeb1030ec6ad35.tar.gz
rails-11a50f48113df300f3225e4963aeb1030ec6ad35.tar.bz2
rails-11a50f48113df300f3225e4963aeb1030ec6ad35.zip
Merge pull request #27598 from NickLaMuro/fix-deep-nesting-where-clauses-with-joins
Fix bug with symbolized keys in .where with nested join
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/associations/has_one_associations_test.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb
index ed22a9802f..aa910ba409 100644
--- a/activerecord/test/cases/associations/has_one_associations_test.rb
+++ b/activerecord/test/cases/associations/has_one_associations_test.rb
@@ -648,6 +648,7 @@ class HasOneAssociationsTest < ActiveRecord::TestCase
class SpecialBook < ActiveRecord::Base
self.table_name = "books"
belongs_to :author, class_name: "SpecialAuthor"
+ has_one :subscription, class_name: "SpecialSupscription", foreign_key: "subscriber_id"
end
class SpecialAuthor < ActiveRecord::Base
@@ -655,6 +656,11 @@ class HasOneAssociationsTest < ActiveRecord::TestCase
has_one :book, class_name: "SpecialBook", foreign_key: "author_id"
end
+ class SpecialSupscription < ActiveRecord::Base
+ self.table_name = "subscriptions"
+ belongs_to :book, class_name: "SpecialBook"
+ end
+
def test_assocation_enum_works_properly
author = SpecialAuthor.create!(name: "Test")
book = SpecialBook.create!(status: "published")
@@ -662,4 +668,15 @@ class HasOneAssociationsTest < ActiveRecord::TestCase
refute_equal 0, SpecialAuthor.joins(:book).where(books: { status: "published" }).count
end
+
+ def test_assocation_enum_works_properly_with_nested_join
+ author = SpecialAuthor.create!(name: "Test")
+ book = SpecialBook.create!(status: "published")
+ author.book = book
+
+ where_clause = { books: { subscriptions: { subscriber_id: nil } } }
+ assert_nothing_raised do
+ SpecialAuthor.joins(book: :subscription).where.not(where_clause)
+ end
+ end
end