From b168439182be2eb900817e587db9b48cd3ac50cb Mon Sep 17 00:00:00 2001 From: Tim Chambers Date: Thu, 8 Nov 2018 15:41:34 -0800 Subject: [PATCH] Force actual query execution Rails 4 defers execution till needed --- test/cases/has_many_test.rb | 2 +- test/cases/self_grouping_test.rb | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/test/cases/has_many_test.rb b/test/cases/has_many_test.rb index d721750..dfbf9cc 100644 --- a/test/cases/has_many_test.rb +++ b/test/cases/has_many_test.rb @@ -70,7 +70,7 @@ class GroupedScope::HasManyTest < GroupedScope::TestCase it 'use association extension SQL along with group reflection' do assert_sql(select_from_reports, where_for_groups(@e2.group_id), where_for_urgent_title) do - @e2.group.reports.urgent + @e2.group.reports.urgent.load end end diff --git a/test/cases/self_grouping_test.rb b/test/cases/self_grouping_test.rb index d116e10..e01efa8 100644 --- a/test/cases/self_grouping_test.rb +++ b/test/cases/self_grouping_test.rb @@ -30,10 +30,9 @@ class GroupedScope::SelfGrouppingTest < GroupedScope::TestCase it 'return correct predicate for GroupedScope::SelfGroupping object' do @employee.update_attribute :group_id, 82 - expected_sql = /"group_id" IN \(SELECT "employees"\."id" FROM "employees" WHERE "employees"\."group_id" = 82/ - assert_sql(expected_sql) { Employee.where(:group_id => @employee.group).all } - assert_sql(expected_sql) { Employee.all(:conditions => {:group_id => @employee.group}) } - assert_equal [@employee], Employee.where(:group_id => @employee.group).all + expected_sql = /"group_id" IN \(SELECT "employees"\."id" FROM "employees" WHERE "employees"\."group_id" = / + assert_sql(expected_sql) { Employee.where(:group_id => @employee.group).load } + assert_equal [@employee], Employee.where(:group_id => @employee.group).load end it 'allows you to ask if the group is present' do