Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update #format for :subunit_to_unit == 1

  • Loading branch information...
commit 507ef24354710a5566879ba5cbc3351cb67393a6 1 parent e7afe97
@semmons99 semmons99 authored
Showing with 5 additions and 1 deletion.
  1. +1 −1  lib/money/money.rb
  2. +4 −0 test/money_spec.rb
View
2  lib/money/money.rb
@@ -373,7 +373,7 @@ def format(*rules)
symbol_value = symbol
end
- if rules[:no_cents]
+ if rules[:no_cents] or currency.subunit_to_unit == 1
formatted = sprintf("#{symbol_value}%d", cents.to_f / currency.subunit_to_unit)
else
formatted = sprintf("#{symbol_value}%.2f", cents.to_f / currency.subunit_to_unit)
View
4 test/money_spec.rb
@@ -484,6 +484,10 @@ def to_money
Money.new(10_00, "BHD").format.should == "ب.د1.00"
end
+ it "doesn't display a decimal when :subunit_to_unit is 1" do
+ Money.new(10_00, "CLP").format.should == "$1.000"
+ end
+
specify "respects the delimiter and separator defaults" do
one_thousand = Proc.new do |currency|
Money.new(1000_00, currency).format
Please sign in to comment.
Something went wrong with that request. Please try again.