From fc985437021dfe2f681e1389faee64dcb067bfa6 Mon Sep 17 00:00:00 2001 From: Hakan Ensari Date: Sat, 17 Mar 2018 14:26:59 +0000 Subject: [PATCH] Fix quoting amount to specific currency when base is Euro --- lib/quotation.rb | 2 +- spec/quotation_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/quotation.rb b/lib/quotation.rb index 1a36860..c0c050d 100644 --- a/lib/quotation.rb +++ b/lib/quotation.rb @@ -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) diff --git a/spec/quotation_spec.rb b/spec/quotation_spec.rb index 47c95a4..bfa4317 100644 --- a/spec/quotation_spec.rb +++ b/spec/quotation_spec.rb @@ -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