diff --git a/app/models/wallet.rb b/app/models/wallet.rb index d9a8165e154..d6b45008dfd 100644 --- a/app/models/wallet.rb +++ b/app/models/wallet.rb @@ -13,6 +13,8 @@ class Wallet < ApplicationRecord monetize :balance_cents, :ongoing_balance_cents, :ongoing_usage_balance_cents monetize :consumed_amount_cents + validates :rate_amount, numericality: {greater_than: 0} + STATUSES = [ :active, :terminated diff --git a/spec/models/wallet_spec.rb b/spec/models/wallet_spec.rb index aeb3edd3417..f8133f85326 100644 --- a/spec/models/wallet_spec.rb +++ b/spec/models/wallet_spec.rb @@ -5,6 +5,10 @@ RSpec.describe Wallet, type: :model do subject(:wallet) { build(:wallet) } + describe 'validations' do + it { is_expected.to validate_numericality_of(:rate_amount).is_greater_than(0) } + end + describe 'currency=' do it 'assigns the currency to all amounts' do wallet.currency = 'CAD'