Skip to content

Commit

Permalink
Force actual query execution
Browse files Browse the repository at this point in the history
Rails 4 defers execution till needed
  • Loading branch information
tjchambers committed Nov 8, 2018
1 parent 2c9a55f commit b168439
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/cases/has_many_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 3 additions & 4 deletions test/cases/self_grouping_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b168439

Please sign in to comment.