Sha256: 6b779cf9fe7778fd95ac3180ee4ab368fc5e8a32a8d3c80629c28b3843cda4ef

Contents?: true

Size: 1.29 KB

Versions: 5

Compression:

Stored size: 1.29 KB

Contents

require 'test_helper'

module Workarea
  class AdminRedemptionsExportTest < IntegrationTest
    def test_total
      Workarea.config.per_page = 5
      Workarea.config.bulk_action_per_page = 5

      card = create_gift_card(amount: 20)
      create_gift_card_redemption(gift_card: card, amount: 10)
      create_gift_card_redemption(gift_card: card, amount: 10)
      query = Search::AdminGiftCards.new

      export = AdminRedemptionsExport.new(gift_cards_query_id: query.to_gid_param)
      assert_equal(2, export.total)

      15.times do
        card = create_gift_card(amount: 20)
        create_gift_card_redemption(gift_card: card, amount: 10)
      end

      export = AdminRedemptionsExport.new(gift_cards_query_id: query.to_gid_param)
      assert_equal(17, export.total)
    end

    def test_scroll
      Workarea.config.bulk_action_per_page = 2

      5.times do
        card = create_gift_card(amount: 20)
        create_gift_card_redemption(gift_card: card, amount: 10)
      end

      query = Search::AdminGiftCards.new
      export = AdminRedemptionsExport.new(gift_cards_query_id: query.to_gid_param)
      count = 0
      passes = 0

      export.scroll do |results|
        count += results.size
        passes += 1
      end

      assert_equal(5, count)
      assert_equal(3, passes)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
workarea-gift_cards-4.0.3 test/queries/workarea/admin_redemptions_export_test.rb
workarea-gift_cards-4.0.2 test/queries/workarea/admin_redemptions_export_test.rb
workarea-gift_cards-4.0.1 test/queries/workarea/admin_redemptions_export_test.rb
workarea-gift_cards-4.0.0 test/queries/workarea/admin_redemptions_export_test.rb
workarea-gift_cards-4.0.0.beta.1 test/queries/workarea/admin_redemptions_export_test.rb