From f0dc2a02a508baf523ae64a4ff7ca6e09bb8373f Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 8 Mar 2018 11:42:20 +0100 Subject: [PATCH] Add Budget#formatted_amount unit test --- spec/models/budget_spec.rb | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/spec/models/budget_spec.rb b/spec/models/budget_spec.rb index 80f0a0c94..72b521861 100644 --- a/spec/models/budget_spec.rb +++ b/spec/models/budget_spec.rb @@ -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