Skip to content

Commit

Permalink
Fix ConditionNotSupportedError raise
Browse files Browse the repository at this point in the history
This constant does not exist in this scope. Running the test in the PR
without the associated code change results in: "uninitialized constant
JobIteration::ActiveRecordBatchEnumerator::ConditionNotSupportedError"
  • Loading branch information
packrat386 committed Oct 23, 2022
1 parent db71632 commit 9a74518
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/job-iteration/active_record_batch_enumerator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def initialize(relation, columns: nil, batch_size: 100, cursor: nil)
end

if relation.arel.orders.present? || relation.arel.taken.present?
raise ConditionNotSupportedError
raise JobIteration::ActiveRecordCursor::ConditionNotSupportedError
end

@base_relation = relation.reorder(@columns.join(","))
Expand Down
6 changes: 6 additions & 0 deletions test/unit/active_record_batch_enumerator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ class ActiveRecordBatchEnumeratorTest < IterationUnitTest
assert_equal expected_num_queries, queries.size
end

test "enumerator will raise ConditionNotSupportedError if the relation is ordered" do
assert_raise(JobIteration::ActiveRecordCursor::ConditionNotSupportedError) do
build_enumerator(relation: Product.order(created_at: :desc))
end
end

private

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

0 comments on commit 9a74518

Please sign in to comment.