1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-21 15:54:22 +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 :wallet
belongs_to :reservation belongs_to :reservation
belongs_to :transactable, polymorphic: true belongs_to :transactable, polymorphic: true
validates_inclusion_of :transaction_type, in: %w( credit debit )
end end

View File

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