diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2019-02-26 21:57:10 -0500 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2019-02-26 21:58:42 -0500 |
commit | 1059dede4c4a1c042e3f4fe9f7fbfcc78146b233 (patch) | |
tree | faac9f9dca234b085fbb4ee5e8c5365ece4e82ab /activerecord | |
parent | f64043b7cb5b5b2cfdfc8df350437637dcfbd17c (diff) | |
download | rails-1059dede4c4a1c042e3f4fe9f7fbfcc78146b233.tar.gz rails-1059dede4c4a1c042e3f4fe9f7fbfcc78146b233.tar.bz2 rails-1059dede4c4a1c042e3f4fe9f7fbfcc78146b233.zip |
Fix test that was broken by adding a default scope to an existing model
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/associations/has_many_through_associations_test.rb | 4 | ||||
-rw-r--r-- | activerecord/test/models/author.rb | 7 | ||||
-rw-r--r-- | activerecord/test/models/post.rb | 1 |
3 files changed, 10 insertions, 2 deletions
diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb index 6f23a832ef..67e013c6e0 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -56,11 +56,11 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase end def test_preload_with_nested_association - posts = Post.preload(:author, :author_favorites).to_a + posts = Post.preload(:author, :author_favorites_with_scope).to_a assert_no_queries do posts.each(&:author) - posts.each(&:author_favorites) + posts.each(&:author_favorites_with_scope) end end diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb index 3eb8a3a0fa..67be59a1fe 100644 --- a/activerecord/test/models/author.rb +++ b/activerecord/test/models/author.rb @@ -217,6 +217,13 @@ class AuthorAddress < ActiveRecord::Base end class AuthorFavorite < ActiveRecord::Base + belongs_to :author + belongs_to :favorite_author, class_name: "Author" +end + +class AuthorFavoriteWithScope < ActiveRecord::Base + self.table_name = "author_favorites" + default_scope { order(id: :asc) } belongs_to :author diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb index c6eb77dba4..a83ef983b8 100644 --- a/activerecord/test/models/post.rb +++ b/activerecord/test/models/post.rb @@ -78,6 +78,7 @@ class Post < ActiveRecord::Base has_many :comments_with_extend_2, extend: [NamedExtension, NamedExtension2], class_name: "Comment", foreign_key: "post_id" has_many :author_favorites, through: :author + has_many :author_favorites_with_scope, through: :author, class_name: "AuthorFavorite", source: "author_favorites" has_many :author_categorizations, through: :author, source: :categorizations has_many :author_addresses, through: :author has_many :author_address_extra_with_address, |