diff options
Diffstat (limited to 'spec/models/concerns/each_batch_spec.rb')
-rw-r--r-- | spec/models/concerns/each_batch_spec.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/models/concerns/each_batch_spec.rb b/spec/models/concerns/each_batch_spec.rb index 8b70753633c..5f4e5d4bd98 100644 --- a/spec/models/concerns/each_batch_spec.rb +++ b/spec/models/concerns/each_batch_spec.rb @@ -56,5 +56,21 @@ RSpec.describe EachBatch do it_behaves_like 'each_batch handling', {} it_behaves_like 'each_batch handling', { order_hint: :updated_at } + + it 'orders ascending by default' do + ids = [] + + model.each_batch(of: 1) { |rel| ids.concat(rel.ids) } + + expect(ids).to eq(ids.sort) + end + + it 'accepts descending order' do + ids = [] + + model.each_batch(of: 1, order: :desc) { |rel| ids.concat(rel.ids) } + + expect(ids).to eq(ids.sort.reverse) + end end end |