mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-04 04:55:20 +02:00
Centralize entry naming (#2454)
* Centralize entry naming * Lint fixes, code style
This commit is contained in:
parent
afbfb474c2
commit
9110ab27d2
12 changed files with 187 additions and 16 deletions
23
test/models/trade_test.rb
Normal file
23
test/models/trade_test.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
require "test_helper"
|
||||
|
||||
class TradeTest < ActiveSupport::TestCase
|
||||
test "build_name generates buy trade name" do
|
||||
name = Trade.build_name("buy", 10, "AAPL")
|
||||
assert_equal "Buy 10.0 shares of AAPL", name
|
||||
end
|
||||
|
||||
test "build_name generates sell trade name" do
|
||||
name = Trade.build_name("sell", 5, "MSFT")
|
||||
assert_equal "Sell 5.0 shares of MSFT", name
|
||||
end
|
||||
|
||||
test "build_name handles absolute value for negative quantities" do
|
||||
name = Trade.build_name("sell", -5, "GOOGL")
|
||||
assert_equal "Sell 5.0 shares of GOOGL", name
|
||||
end
|
||||
|
||||
test "build_name handles decimal quantities" do
|
||||
name = Trade.build_name("buy", 0.25, "BTC")
|
||||
assert_equal "Buy 0.25 shares of BTC", name
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue