diff --git a/app/models/concerns/amount_concern.rb b/app/models/concerns/amount_concern.rb index 86b01b443..b2d07d050 100644 --- a/app/models/concerns/amount_concern.rb +++ b/app/models/concerns/amount_concern.rb @@ -8,7 +8,7 @@ module AmountConcern if amount.nil? write_attribute(:amount, amount) else - write_attribute(:amount, amount.to_i * 100) + write_attribute(:amount, (amount * 100).to_i) end end diff --git a/test/integration/wallets_test.rb b/test/integration/wallets_test.rb index 5ace5e4af..bc9c89aac 100644 --- a/test/integration/wallets_test.rb +++ b/test/integration/wallets_test.rb @@ -61,7 +61,7 @@ class WalletsTest < ActionDispatch::IntegrationTest admin = users(:user_1) login_as(admin, scope: :user) w = @vlonchamp.wallet - amount = 10 + amount = 10.5 expected_amount = w.amount + amount put "/api/wallet/#{w.id}/credit", { diff --git a/test/models/wallet_test.rb b/test/models/wallet_test.rb index 537ae6bdf..7eb1fbb01 100644 --- a/test/models/wallet_test.rb +++ b/test/models/wallet_test.rb @@ -13,8 +13,8 @@ class WalletTest < ActiveSupport::TestCase test 'can credit amount' do w = Wallet.first - expected_amount = w.amount + 5 - assert w.credit(5) + expected_amount = w.amount + 5.5 + assert w.credit(5.5) assert_equal w.amount, expected_amount end