Sha256: 0ee3f4451ec27a279805f87723842568767368643f36a77b63b3d325cdee65f5

Contents?: true

Size: 1.2 KB

Versions: 34

Compression:

Stored size: 1.2 KB

Contents

require 'test_helper'

module Workarea
  class Checkout
    class CollectPaymentTest < TestCase
      def order
        @order ||= Order.new(email: 'test@workarea.com', total_price: 5.to_m)
      end

      def checkout
        @checkout ||= Checkout.new(order)
      end

      def collect_payment
        @collect_payment ||= CollectPayment.new(checkout)
      end

      def test_valid?
        refute(collect_payment.valid?)
        assert_equal(1, checkout.payment.errors[:base].length)
      end

      def test_purchase
        refute(collect_payment.purchase)

        order.total_price = 0.to_m
        assert(collect_payment.purchase)

        order.total_price = 5.to_m

        checkout.payment.profile = create_payment_profile(
          email: order.email,
          store_credit: 20.to_m
        )
        checkout.payment.build_store_credit(amount: 5.to_m)

        assert(collect_payment.purchase)
      end

      def test_action
        Workarea.with_config do |config|
          config.auto_capture = false
          assert_equal('authorize!', collect_payment.action)

          config.auto_capture = true
          assert_equal('purchase!', collect_payment.action)
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-core-3.4.45 test/models/workarea/checkout/collect_payment_test.rb
workarea-core-3.4.44 test/models/workarea/checkout/collect_payment_test.rb
workarea-core-3.4.43 test/models/workarea/checkout/collect_payment_test.rb
workarea-core-3.4.42 test/models/workarea/checkout/collect_payment_test.rb
workarea-core-3.4.41 test/models/workarea/checkout/collect_payment_test.rb
workarea-core-3.4.40 test/models/workarea/checkout/collect_payment_test.rb
workarea-core-3.4.39 test/models/workarea/checkout/collect_payment_test.rb
workarea-core-3.4.38 test/models/workarea/checkout/collect_payment_test.rb
workarea-core-3.4.37 test/models/workarea/checkout/collect_payment_test.rb
workarea-core-3.4.36 test/models/workarea/checkout/collect_payment_test.rb
workarea-core-3.4.35 test/models/workarea/checkout/collect_payment_test.rb
workarea-core-3.4.34 test/models/workarea/checkout/collect_payment_test.rb
workarea-core-3.4.33 test/models/workarea/checkout/collect_payment_test.rb
workarea-core-3.4.32 test/models/workarea/checkout/collect_payment_test.rb
workarea-core-3.4.31 test/models/workarea/checkout/collect_payment_test.rb
workarea-core-3.4.30 test/models/workarea/checkout/collect_payment_test.rb
workarea-core-3.4.29 test/models/workarea/checkout/collect_payment_test.rb
workarea-core-3.4.28 test/models/workarea/checkout/collect_payment_test.rb
workarea-core-3.4.27 test/models/workarea/checkout/collect_payment_test.rb
workarea-core-3.4.26 test/models/workarea/checkout/collect_payment_test.rb