Shopify/money

Two money objects are equal when value are the same but one of the currency is NullCurrency

wendy-shopify opened this issue · 1 comments

When trying to do equality, two following objects will actually be equal

money_1 = Money.new(10, "USD")
money_2 = Money.new(10)

> money_1 == money_2
=> true

I found the reason is due to checking currency.compatible? then currency.eql? when implementing money.eql?

this is expected behaviour, the null currency is compatible with all other currencies. If you don't want this behaviour make sure you didn't opt in using config.legacy_default_currency! (if you still want to use a default currency, set it explicitly config.default_currency = "USD")