From 32a69da269b3fd7ac5dc4536ce19be3aca76d199 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Wed, 3 Mar 2021 15:58:27 +0100 Subject: [PATCH] Let's simplify the internal assertion here, doesn't need to a yield argument --- activerecord/test/cases/excluding_test.rb | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/activerecord/test/cases/excluding_test.rb b/activerecord/test/cases/excluding_test.rb index b5fbf0e89b..f314b0a197 100644 --- a/activerecord/test/cases/excluding_test.rb +++ b/activerecord/test/cases/excluding_test.rb @@ -46,15 +46,10 @@ class ExcludingTest < ActiveRecord::TestCase end def test_does_not_exclude_records_when_no_arguments - assert_does_not_exclude_records { Post.excluding() } - end - - def test_does_not_exclude_records_with_empty_collection_argument - assert_does_not_exclude_records { Post.excluding([]) } - end - - def test_does_not_exclude_records_with_a_nil_argument - assert_does_not_exclude_records { Post.excluding(nil) } + assert_no_excludes Post.excluding + assert_no_excludes Post.excluding(nil) + assert_no_excludes Post.excluding([]) + assert_no_excludes Post.excluding([ nil ]) end def test_raises_on_record_from_different_class @@ -74,8 +69,8 @@ class ExcludingTest < ActiveRecord::TestCase end private - def assert_does_not_exclude_records - assert_includes yield, posts(:welcome) - assert_equal Post.count, yield.count + def assert_no_excludes(relation) + assert_includes relation, posts(:welcome) + assert_equal Post.count, relation.count end end