Add Budget#formatted_amount unit test

This commit is contained in:
Bertocq
2018-03-08 11:42:20 +01:00
parent b72e43168b
commit f0dc2a02a5

View File

@@ -228,4 +228,38 @@ describe Budget do
expect(finished_phase.prev_phase).to eq(reviewing_ballots_phase)
end
end
describe "#formatted_amount" do
after do
I18n.locale = :en
end
it "correctly formats Euros with Spanish" do
budget.update(currency_symbol: '€')
I18n.locale = :es
expect(budget.formatted_amount(1000.00)).to eq ('1.000 €')
end
it "correctly formats Dollars with Spanish" do
budget.update(currency_symbol: '$')
I18n.locale = :es
expect(budget.formatted_amount(1000.00)).to eq ('1.000 $')
end
it "correctly formats Dollars with English" do
budget.update(currency_symbol: '$')
I18n.locale = :en
expect(budget.formatted_amount(1000.00)).to eq ('$1,000')
end
it "correctly formats Euros with English" do
budget.update(currency_symbol: '€')
I18n.locale = :en
expect(budget.formatted_amount(1000.00)).to eq ('€1,000')
end
end
end