2019-07-30 21:29:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-25 16:15:39 +00:00
|
|
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
2018-03-25 17:30:42 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe CalculateFees do
|
2019-07-30 21:29:24 +00:00
|
|
|
describe '.for_single_amount' do
|
|
|
|
it 'returns 2.2% + platform fee + 30 cents for an online donation' do
|
|
|
|
expect(CalculateFees.for_single_amount(10_000, 0.018)).to eq(430)
|
|
|
|
end
|
2018-03-25 17:30:42 +00:00
|
|
|
|
|
|
|
it 'returns 2.2% + + 30 cents for an online donation with no platform fee' do
|
2019-07-30 21:29:24 +00:00
|
|
|
expect(CalculateFees.for_single_amount(10_000)).to eq(250)
|
|
|
|
end
|
|
|
|
|
2018-03-25 17:30:42 +00:00
|
|
|
it 'returns 2.2% + platform fee + 30 cents for an online donation with higher platform fee' do
|
2019-07-30 21:29:24 +00:00
|
|
|
expect(CalculateFees.for_single_amount(10_000, 0.038)).to eq(630)
|
|
|
|
end
|
2018-03-25 17:30:42 +00:00
|
|
|
|
|
|
|
it 'raises an error with a negative amount' do
|
2019-07-30 21:29:24 +00:00
|
|
|
expect { CalculateFees.for_single_amount(-10, 0.01) }.to raise_error(ParamValidation::ValidationError)
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|
2019-07-30 21:29:24 +00:00
|
|
|
|
2018-03-25 17:30:42 +00:00
|
|
|
it 'raises an error with a negative fee' do
|
2019-07-30 21:29:24 +00:00
|
|
|
expect { CalculateFees.for_single_amount(1000, -0.01) }.to raise_error(ParamValidation::ValidationError)
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|
2019-07-30 21:29:24 +00:00
|
|
|
end
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|