diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2017-07-24 10:11:57 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-24 10:11:57 -0400 |
commit | 01425d8a714d05f3f906908e95ca29376af74c42 (patch) | |
tree | 5c97efa5e1d71447247022e053de6a31b12cb604 /activerecord | |
parent | 2eaa7be638854ec513be4966f526f2564aecb7dd (diff) | |
parent | f232642879d1f52c7e60a246cb82eae1a90dffd4 (diff) | |
download | rails-01425d8a714d05f3f906908e95ca29376af74c42.tar.gz rails-01425d8a714d05f3f906908e95ca29376af74c42.tar.bz2 rails-01425d8a714d05f3f906908e95ca29376af74c42.zip |
Merge pull request #29905 from kamipo/remove_duplicated_assertion
Remove duplicated assertion in `test_count_with_join`
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/base_test.rb | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 5dbb7f788a..1d33564989 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1054,29 +1054,15 @@ class BasicsTest < ActiveRecord::TestCase def test_count_with_join res = Post.count_by_sql "SELECT COUNT(*) FROM posts LEFT JOIN comments ON posts.id=comments.post_id WHERE posts.#{QUOTED_TYPE} = 'Post'" - res2 = Post.where("posts.#{QUOTED_TYPE} = 'Post'").joins("LEFT JOIN comments ON posts.id=comments.post_id").count assert_equal res, res2 - res3 = nil - assert_nothing_raised do - res3 = Post.where("posts.#{QUOTED_TYPE} = 'Post'").joins("LEFT JOIN comments ON posts.id=comments.post_id").count - end - assert_equal res, res3 - res4 = Post.count_by_sql "SELECT COUNT(p.id) FROM posts p, comments co WHERE p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id" - res5 = nil - assert_nothing_raised do - res5 = Post.where("p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id").joins("p, comments co").select("p.id").count - end - + res5 = Post.where("p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id").joins("p, comments co").select("p.id").count assert_equal res4, res5 res6 = Post.count_by_sql "SELECT COUNT(DISTINCT p.id) FROM posts p, comments co WHERE p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id" - res7 = nil - assert_nothing_raised do - res7 = Post.where("p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id").joins("p, comments co").select("p.id").distinct.count - end + res7 = Post.where("p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id").joins("p, comments co").select("p.id").distinct.count assert_equal res6, res7 end |