Skip to content

Commit

Permalink
Money#format: correctly format symbol according to currency when :sym…
Browse files Browse the repository at this point in the history
…bol option is not given.
  • Loading branch information
FooBarWidget committed Nov 5, 2009
1 parent b723ad9 commit fd228db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/money/money.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def format(*rules)
symbol = ""
end
else
symbol = "$"
symbol = SYMBOLS[currency] || "$"
end

if rules[:no_cents]
Expand Down
11 changes: 11 additions & 0 deletions test/money_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,17 @@
money.format(:symbol => false).should == "1.00"
end

specify "#format without :symbol assumes that :symbol is set to true" do
money = Money.new(100)
money.format.should == "$1.00"

money = Money.new(100, "GBP")
money.format.should == "£1.00"

money = Money.new(100, "XYZ")
money.format.should == "$1.00"
end

specify "#format(:html => true) works as documented" do
string = Money.ca_dollar(570).format(:html => true, :with_currency => true)
string.should == "$5.70 <span class=\"currency\">CAD</span>"
Expand Down

0 comments on commit fd228db

Please sign in to comment.