Skip to content

Commit

Permalink
Test case for asserting on integer conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
pedropb committed Feb 14, 2024
1 parent ff5935d commit f71d0ac
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/unit/active_record_enumerator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

module JobIteration
class ActiveRecordEnumeratorTest < IterationUnitTest
include ActiveRecordHelpers

SQL_TIME_FORMAT = "%Y-%m-%d %H:%M:%S.%N"
test "#records yields every record with their cursor position" do
enum = build_enumerator.records
Expand Down Expand Up @@ -133,6 +135,13 @@ class ActiveRecordEnumeratorTest < IterationUnitTest
end
end

test "enumerator paginates using integer conditionals for primary key when no columns are defined" do
enum = build_enumerator(relation: Product.all, batch_size: 1).records
assert_sql(/`products`\.`id` > 1/) do
enum.take(2)
end
end

private

def build_enumerator(relation: Product.all, batch_size: 2, columns: nil, cursor: nil)
Expand Down

0 comments on commit f71d0ac

Please sign in to comment.