Sha256: 36546867d0b1a0df03e5c549ae44f7f3bbcb733e94a0c34ff50f628cfcfadfb9
Contents?: true
Size: 1.58 KB
Versions: 3
Compression:
Stored size: 1.58 KB
Contents
require 'test_helper' module Billing class AccountTest < ActiveSupport::TestCase setup do @account = billing_accounts(:one) @account.save! # force summary calculation end test "charge" do charge = @account.charge 3 assert charge.try(:persisted?) assert_equal '13 USD'.to_money, @account.total # (1 + 3) + 100% + $1 end test "discount" do discount = @account.modify(-1.00, charge: billing_charges(:two)) assert discount.try(:persisted?) assert_equal '6 USD'.to_money, @account.total end test "surcharge" do surcharge = @account.modify(1.00, charge: billing_charges(:two)) assert surcharge.try(:persisted?) assert_equal '8 USD'.to_money, @account.total end test "pay" do payment = @account.pay billing_payment_types(:one) assert @account.balance.zero?, @account.errors.full_messages.join(', ') assert_equal '7 USD'.to_money, @account.payments_sum end test "validate positive total" do assert @account.save @account.modify(-500) assert @account.errors.messages[:total] assert_raise ActiveRecord::RecordInvalid do @account.save! end end test "account with payments should have origin" do assert @account.origin assert @account.payments.any? @account.origin = nil assert_equal false, @account.save assert @account.errors.messages[:origin] end test "autofin" do assert @account.pay billing_payment_types(:one) assert @account.finalized_at end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
billing-0.0.4b | test/models/billing/account_test.rb |
billing-0.0.4a | test/models/billing/account_test.rb |
billing-0.0.4 | test/models/billing/account_test.rb |