Skip to content

Commit

Permalink
fixup! Update billing helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
gbp committed Nov 11, 2024
1 parent 04f5ee6 commit 7ada4b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/helpers/alaveteli_pro/plan_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions spec/helpers/alaveteli_pro/plan_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7ada4b3

Please sign in to comment.