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.4.27 test/models/workarea/payment/profile_test.rb
workarea-core-3.5.4 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.26 test/models/workarea/payment/profile_test.rb
workarea-core-3.5.3 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.25 test/models/workarea/payment/profile_test.rb
workarea-core-3.5.2 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.24 test/models/workarea/payment/profile_test.rb
workarea-core-3.5.1 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.23 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.22 test/models/workarea/payment/profile_test.rb
workarea-core-3.5.0 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.21 test/models/workarea/payment/profile_test.rb
workarea-core-3.5.0.beta.1 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.20 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.19 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.18 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.17 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.16 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.15 test/models/workarea/payment/profile_test.rb
workarea-core-3.4.14 test/models/workarea/payment/profile_test.rb