1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

wallet transaction type must be credit/debit

This commit is contained in:
Peng DU 2016-07-05 12:15:26 +02:00
parent b22bae1d8f
commit 9116e8c04a
2 changed files with 11 additions and 3 deletions

View File

@ -3,4 +3,6 @@ class WalletTransaction < ActiveRecord::Base
belongs_to :wallet
belongs_to :reservation
belongs_to :transactable, polymorphic: true
validates_inclusion_of :transaction_type, in: %w( credit debit )
end

View File

@ -1,7 +1,13 @@
require 'test_helper'
class WalletTransactionTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
test 'transaction type must be credit or debit' do
transaction = WalletTransaction.new
transaction.transaction_type = 'credit'
assert transaction.valid?
transaction.transaction_type = 'debit'
assert transaction.valid?
transaction.transaction_type = 'other'
assert_not transaction.valid?
end
end