Fix quoting amount to specific currency when base is Euro

This commit is contained in:
Hakan Ensari 2018-03-17 14:26:59 +00:00
parent 5e1ccaa5ef
commit fc98543702
2 changed files with 9 additions and 1 deletions

View File

@ -32,7 +32,7 @@ class Quotation
return rates if @base == DEFAULT_BASE && @amount == 1.0
if @symbols.nil? || @symbols.include?(DEFAULT_BASE)
if @symbols.nil? || @symbols.include?(DEFAULT_BASE) || @base == DEFAULT_BASE
rates.update(DEFAULT_BASE => 1.0)
end
divisor = rates.delete(@base)

View File

@ -42,4 +42,12 @@ describe Quotation do
rates['USD'].must_be :>, 10
end
end
describe 'when given an amount and symbols' do
it 'quotes for that amount' do
quotation = Quotation.new(amount: 100, symbols: ['USD'])
rates = quotation.quote[:rates]
rates['USD'].must_be :>, 10
end
end
end