The personal finance app for everyone (by everyone)
Ruby
fix: Preserve MXN separators in Spanish locale (#3651)
Oscar Maciel Caamal Cetinabd783290e4bd
diff --git a/lib/money/formatting.rb b/lib/money/formatting.rbindex 4c674c6c5f..bbaad9ebaa 100644--- a/lib/money/formatting.rb+++ b/lib/money/formatting.rb@@ -41,6 +41,8 @@ module Money::Formattingdef locale_options(locale)locale_sym = (locale || I18n.locale || :en).to_sym+ return { format: "%n %u" } if currency.iso_code == "MXN" && locale_sym == :es+# French locale: uses non-breaking spaces (unique formatting)if locale_sym == :frreturn { delimiter: "\u00A0", separator: ",", format: "%n\u00A0%u" }diff --git a/test/lib/money_test.rb b/test/lib/money_test.rbindex 21f603adce..dd217f76cc 100644--- a/test/lib/money_test.rb+++ b/test/lib/money_test.rb@@ -108,6 +108,7 @@ class MoneyTest < ActiveSupport::TestCasetest "formats correctly for Spanish locale" doassert_equal "1.000,12 €", Money.new(1000.12, :eur).format(locale: :es)+ assert_equal "100.12 MX$", Money.new(100.12, :mxn).format(locale: :es)endtest "formats correctly for Italian locale" do