From 7ada4b3b7fbd1be9c22bd0a83c7d92dee024e022 Mon Sep 17 00:00:00 2001 From: Graeme Porteous Date: Mon, 11 Nov 2024 12:01:22 +0000 Subject: [PATCH] fixup! Update billing helper methods --- app/helpers/alaveteli_pro/plan_helper.rb | 4 ++-- spec/helpers/alaveteli_pro/plan_helper_spec.rb | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/helpers/alaveteli_pro/plan_helper.rb b/app/helpers/alaveteli_pro/plan_helper.rb index 7bc3fb5065..af002445e8 100644 --- a/app/helpers/alaveteli_pro/plan_helper.rb +++ b/app/helpers/alaveteli_pro/plan_helper.rb @@ -13,13 +13,13 @@ def billing_frequency(plan) elsif interval(plan) == 'year' && interval_count(plan) == 1 _('Billed: Annually') else - _('Billed: every {{interval}}', interval: interval(plan)) + _('Billed: every {{interval}}', interval: pluralize_interval(plan)) end end def billing_interval(plan) if interval_count(plan) == 1 - _('per user, per {{interval}}', interval: pluralize_interval(plan)) + _('per user, per {{interval}}', interval: interval(plan)) else _('per user, every {{interval}}', interval: pluralize_interval(plan)) end diff --git a/spec/helpers/alaveteli_pro/plan_helper_spec.rb b/spec/helpers/alaveteli_pro/plan_helper_spec.rb index bdcab955b1..ae85075529 100644 --- a/spec/helpers/alaveteli_pro/plan_helper_spec.rb +++ b/spec/helpers/alaveteli_pro/plan_helper_spec.rb @@ -33,6 +33,12 @@ allow(plan).to receive(:interval_count).and_return(1) expect(helper.billing_frequency(plan)).to eq('Billed: every quarter') end + + it 'returns custom message for intervals with count greater then 1' do + allow(plan).to receive(:interval).and_return('week') + allow(plan).to receive(:interval_count).and_return(2) + expect(helper.billing_frequency(plan)).to eq('Billed: every 2 weeks') + end end describe '#billing_interval' do