Do not modify the HTML returned by Money gem

It was due to these lines that we were returning a broken HTML tag but
also, there's no need to remove blanks.
This commit is contained in:
Pau Perez
2021-03-10 16:22:22 +01:00
parent 9c642e2957
commit 0eb14bc0a4
2 changed files with 2 additions and 8 deletions

View File

@@ -28,13 +28,7 @@ module Spree
end
def to_html(options = { html_wrap: true })
output = @money.format(@options.merge(options))
if options[:html_wrap]
# 1) prevent blank, breaking spaces
# 2) prevent escaping of HTML character entities
output = output.sub(" ", " ").html_safe
end
output
@money.format(@options.merge(options)).html_safe
end
def format(options = {})

View File

@@ -123,7 +123,7 @@ describe Spree::Money do
money = Spree::Money.new(10)
# The HTMLified version of the euro sign
expect(money.to_html).to eq(
"<span&nbsp;class=\"money-whole\">10</span><span class=\"money-decimal-mark\">.</span><span class=\"money-decimal\">00</span> <span class=\"money-currency-symbol\">&#x20AC;</span>"
"<span class=\"money-whole\">10</span><span class=\"money-decimal-mark\">.</span><span class=\"money-decimal\">00</span> <span class=\"money-currency-symbol\">&#x20AC;</span>"
)
end
# rubocop:enable Layout/LineLength