From 6e64de0f1c3e17dd9fd5a58413c7da8df0163035 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Tue, 17 Sep 2019 15:52:40 +0900 Subject: [PATCH] Silence method redefined warnings Caused by #37120. --- activerecord/test/cases/reflection_test.rb | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/activerecord/test/cases/reflection_test.rb b/activerecord/test/cases/reflection_test.rb index 3794374daa..cc160a5d6e 100644 --- a/activerecord/test/cases/reflection_test.rb +++ b/activerecord/test/cases/reflection_test.rb @@ -541,8 +541,10 @@ class UncastableReflectionTest < ActiveRecord::TestCase teardown do Book._reflections.clear Book.clear_reflections_cache - Subscriber.has_many :books, through: :subscriptions - Subscriber.has_one :book, through: :subscription + silence_warnings do + Subscriber.has_many :books, through: :subscriptions + Subscriber.has_one :book, through: :subscription + end end test "uncastable has_many through: reflection" do @@ -553,11 +555,6 @@ class UncastableReflectionTest < ActiveRecord::TestCase MSG end - test "fixing uncastable has_many through: reflection with has_many" do - Book.has_many :subscriptions - @subscriber.books - end - test "uncastable has_one through: reflection" do error = assert_raises(NotImplementedError) { @subscriber.book } @@ -567,8 +564,17 @@ class UncastableReflectionTest < ActiveRecord::TestCase MSG end + test "fixing uncastable has_many through: reflection with has_many" do + silence_warnings do + Book.has_many :subscriptions + end + @subscriber.books + end + test "fixing uncastable has_one through: reflection with has_many" do - Book.has_many :subscriptions + silence_warnings do + Book.has_many :subscriptions + end @subscriber.book end