Commit d7a2e48eec572ab6d66ff341d2053c1dc07a882f
Committed by
Daniela Feitosa
1 parent
cca918d2
Exists in
staging
and in
42 other branches
Adding precision parameter to float_to_currency_cart
(ActionItem2319)
Showing
2 changed files
with
8 additions
and
1 deletions
Show diff stats
plugins/shopping_cart/lib/shopping_cart_plugin/cart_helper.rb
@@ -55,6 +55,6 @@ module ShoppingCartPlugin::CartHelper | @@ -55,6 +55,6 @@ module ShoppingCartPlugin::CartHelper | ||
55 | end | 55 | end |
56 | 56 | ||
57 | def float_to_currency_cart(value, environment) | 57 | def float_to_currency_cart(value, environment) |
58 | - number_to_currency(value, :unit => environment.currency_unit, :separator => environment.currency_separator, :delimiter => environment.currency_delimiter, :format => "%u %n") | 58 | + number_to_currency(value, :unit => environment.currency_unit, :separator => environment.currency_separator, :delimiter => environment.currency_delimiter, :precision => 2, :format => "%u %n") |
59 | end | 59 | end |
60 | end | 60 | end |
plugins/shopping_cart/test/unit/shopping_cart_plugin/cart_helper_test.rb
@@ -34,5 +34,12 @@ class ShoppingCartPlugin::CartHelperTest < ActiveSupport::TestCase | @@ -34,5 +34,12 @@ class ShoppingCartPlugin::CartHelperTest < ActiveSupport::TestCase | ||
34 | assert_equal price-discount, sell_price(product) | 34 | assert_equal price-discount, sell_price(product) |
35 | end | 35 | end |
36 | 36 | ||
37 | + should 'return the correct formated string with float_to_currency_cart' do | ||
38 | + value = 13.7 | ||
39 | + environment = Environment.default | ||
40 | + | ||
41 | + assert_equal "#{environment.currency_unit} 13#{environment.currency_separator}70", float_to_currency_cart(value,environment) | ||
42 | + end | ||
43 | + | ||
37 | end | 44 | end |
38 | 45 |