1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Remove method redefined warnings for test suite

has_many definitions with "name" as singular and as plural e.g.
  has_many :welcome_posts_with_comment
  has_many :welcome_posts_with_comments

Ruby mentions it with:

lib/active_record/associations/builder/collection_association.rb:65:
  warning: method redefined; discarding old welcome_posts_with_comment_ids
lib/active_record/associations/builder/collection_association.rb:65:
  warning: previous definition of welcome_posts_with_comment_ids was here
lib/active_record/associations/builder/collection_association.rb:75:
  warning: method redefined; discarding old welcome_posts_with_comment_ids=
lib/active_record/associations/builder/collection_association.rb:75:
  warning: previous definition of welcome_posts_with_comment_ids= was here
This commit is contained in:
Matthias Zirnstein 2014-01-05 17:55:39 +01:00
parent 3713e43366
commit bf556880f2
2 changed files with 2 additions and 2 deletions

View file

@ -42,7 +42,7 @@ class InnerJoinAssociationTest < ActiveRecord::TestCase
end end
def test_join_association_conditions_support_string_and_arel_expressions def test_join_association_conditions_support_string_and_arel_expressions
assert_equal 0, Author.joins(:welcome_posts_with_comment).count assert_equal 0, Author.joins(:welcome_posts_with_one_comment).count
assert_equal 1, Author.joins(:welcome_posts_with_comments).count assert_equal 1, Author.joins(:welcome_posts_with_comments).count
end end

View file

@ -29,7 +29,7 @@ class Author < ActiveRecord::Base
has_many :thinking_posts, -> { where(:title => 'So I was thinking') }, :dependent => :delete_all, :class_name => 'Post' has_many :thinking_posts, -> { where(:title => 'So I was thinking') }, :dependent => :delete_all, :class_name => 'Post'
has_many :welcome_posts, -> { where(:title => 'Welcome to the weblog') }, :class_name => 'Post' has_many :welcome_posts, -> { where(:title => 'Welcome to the weblog') }, :class_name => 'Post'
has_many :welcome_posts_with_comment, has_many :welcome_posts_with_one_comment,
-> { where(title: 'Welcome to the weblog').where('comments_count = ?', 1) }, -> { where(title: 'Welcome to the weblog').where('comments_count = ?', 1) },
class_name: 'Post' class_name: 'Post'
has_many :welcome_posts_with_comments, has_many :welcome_posts_with_comments,