Sha256: 90a0f872f3bc59f1e354ad23f3fc6fc1d247d5a3c6ee535096402b5f345281d9

Contents?: true

Size: 741 Bytes

Versions: 2

Compression:

Stored size: 741 Bytes

Contents

require 'test_helper'

class Superstore::ScrollingTest < Superstore::TestCase
  ActiveRecord::Relation.class_eval do
    include Superstore::Relation::Scrolling
  end
  
  test 'scroll_each' do
    Issue.create
    Issue.create

    issues = []
    Issue.all.scroll_each do |issue|
      issues << issue
    end

    assert_equal Issue.all.to_set, issues.to_set
  end

  test 'scroll_in_batches' do
    Issue.create
    Issue.create
    Issue.create

    issue_batches = []
    Issue.all.scroll_in_batches(batch_size: 2) do |issues|
      issue_batches << issues
    end

    assert_equal 2, issue_batches.size
    assert issue_batches.any? { |issues| issues.size == 2 }
    assert issue_batches.any? { |issues| issues.size == 1 }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
superstore-3.0.0 test/unit/relation/scrolling_test.rb
superstore-2.5.0 test/unit/relation/scrolling_test.rb