Sha256: 34c65625b06e06210cfea1d63475f47af69de5653672aa871dcceece1f47b8a6

Contents?: true

Size: 1.28 KB

Versions: 62

Compression:

Stored size: 1.28 KB

Contents

require 'test_helper'

module Workarea
  class Payment
    class ProfileTest < TestCase
      def reference
        @reference ||= PaymentReference.new(create_user)
      end

      def profile
        @profile ||= Profile.lookup(reference)
      end

      def test_default_credit_card
        default = create_saved_credit_card(profile: profile, default: true)
        create_saved_credit_card(profile: profile, default: false)
        assert_equal(default, profile.default_credit_card)

        profile.credit_cards = []
        default = create_saved_credit_card(profile: profile)
        create_saved_credit_card(profile: profile, created_at: Time.current - 1.hour)
        assert_equal(default, profile.default_credit_card)
      end

      def test_purchase_on_store_credit
        profile.update_attributes(store_credit: 10.to_m)

        profile.purchase_on_store_credit(500)
        profile.reload

        assert_equal(5.to_m, profile.store_credit)

        assert_raises(InsufficientFunds) do
          profile.purchase_on_store_credit(5000)
        end
      end

      def test_reload_store_credit
        profile.update_attributes(store_credit: 0.to_m)

        profile.reload_store_credit(500)
        profile.reload

        assert_equal(5.to_m, profile.store_credit)
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/models/workarea/payment/profile_test.rb
workarea-core-3.5.26 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.45 test/models/workarea/payment/profile_test.rb
workarea-core-3.5.25 test/models/workarea/payment/profile_test.rb
workarea-core-3.5.23 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.44 test/models/workarea/payment/profile_test.rb
workarea-core-3.5.22 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.43 test/models/workarea/payment/profile_test.rb
workarea-core-3.5.21 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.42 test/models/workarea/payment/profile_test.rb
workarea-core-3.5.20 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.41 test/models/workarea/payment/profile_test.rb
workarea-core-3.5.19 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.40 test/models/workarea/payment/profile_test.rb
workarea-core-3.5.18 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.39 test/models/workarea/payment/profile_test.rb
workarea-core-3.5.17 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.38 test/models/workarea/payment/profile_test.rb
workarea-core-3.5.16 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.37 test/models/workarea/payment/profile_test.rb