aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2019-02-26 21:57:10 -0500
committerRafael Mendonça França <rafaelmfranca@gmail.com>2019-02-26 21:58:42 -0500
commit1059dede4c4a1c042e3f4fe9f7fbfcc78146b233 (patch)
treefaac9f9dca234b085fbb4ee5e8c5365ece4e82ab
parentf64043b7cb5b5b2cfdfc8df350437637dcfbd17c (diff)
downloadrails-1059dede4c4a1c042e3f4fe9f7fbfcc78146b233.tar.gz
rails-1059dede4c4a1c042e3f4fe9f7fbfcc78146b233.tar.bz2
rails-1059dede4c4a1c042e3f4fe9f7fbfcc78146b233.zip
Fix test that was broken by adding a default scope to an existing model
-rw-r--r--activerecord/test/cases/associations/has_many_through_associations_test.rb4
-rw-r--r--activerecord/test/models/author.rb7
-rw-r--r--activerecord/test/models/post.rb1
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,