Sha256: 6406fc8a1cb7e62dd247a8b1cd93eed6a738f0f83afc6e674f7450142d620de0

Contents?: true

Size: 1.4 KB

Versions: 40

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'

describe Killbill::Plugin::ActiveMerchant::ActiveRecord do

  before(:all) do
    ::Killbill::Test::TestPaymentMethod.delete_all
  end

  it 'should stream results per batch' do
    1.upto(35) do
      ::Killbill::Test::TestPaymentMethod.create(:kb_account_id        => SecureRandom.uuid,
                                                 :kb_payment_method_id => SecureRandom.uuid,
                                                 :kb_tenant_id         => SecureRandom.uuid,
                                                 :token                => SecureRandom.uuid,
                                                 :created_at           => Time.now.utc,
                                                 :updated_at           => Time.now.utc)
    end
    ::Killbill::Test::TestPaymentMethod.count.should == 35

    enum = ::Killbill::Plugin::ActiveMerchant::ActiveRecord::StreamyResultSet.new(40, 10) do |offset, limit|
      ::Killbill::Test::TestPaymentMethod.where('kb_payment_method_id is not NULL')
                                         .order('id ASC')
                                         .offset(offset)
                                         .limit(limit)
    end

    i = 0
    enum.each do |results|
      if i < 3
        results.size.should == 10
      elsif i == 3
        results.size.should == 5
      else
        fail 'Too many results'
      end
      i += 1
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
killbill-9.4.1 spec/killbill/helpers/streamy_result_set_spec.rb
killbill-8.3.6 spec/killbill/helpers/streamy_result_set_spec.rb
killbill-9.4.0 spec/killbill/helpers/streamy_result_set_spec.rb
killbill-9.3.2 spec/killbill/helpers/streamy_result_set_spec.rb
killbill-9.3.1 spec/killbill/helpers/streamy_result_set_spec.rb
killbill-8.3.5 spec/killbill/helpers/streamy_result_set_spec.rb
killbill-9.3.0 spec/killbill/helpers/streamy_result_set_spec.rb
killbill-9.2.2 spec/killbill/helpers/streamy_result_set_spec.rb
killbill-8.3.4 spec/killbill/helpers/streamy_result_set_spec.rb
killbill-8.3.3 spec/killbill/helpers/streamy_result_set_spec.rb
killbill-9.2.1 spec/killbill/helpers/streamy_result_set_spec.rb
killbill-9.2.0 spec/killbill/helpers/streamy_result_set_spec.rb
killbill-8.3.2 spec/killbill/helpers/streamy_result_set_spec.rb
killbill-8.3.1 spec/killbill/helpers/streamy_result_set_spec.rb
killbill-8.3.0 spec/killbill/helpers/streamy_result_set_spec.rb
killbill-8.2.0 spec/killbill/helpers/streamy_result_set_spec.rb
killbill-8.1.0 spec/killbill/helpers/streamy_result_set_spec.rb
killbill-7.0.6 spec/killbill/helpers/streamy_result_set_spec.rb
killbill-8.0.1 spec/killbill/helpers/streamy_result_set_spec.rb
killbill-8.0.0 spec/killbill/helpers/streamy_result_set_spec.rb