File tree Expand file tree Collapse file tree 4 files changed +10
-2
lines changed
Expand file tree Collapse file tree 4 files changed +10
-2
lines changed Original file line number Diff line number Diff line change 44.config
55.yardoc
66Gemfile.lock
7+ vendor /bundle
78InstalledFiles
89_yardoc
910coverage
Original file line number Diff line number Diff line change 11# Changelog
22
33## Unreleased
4+ - Fix parsing of ISO codes not in ` Monetize::Parser::CURRENCY_SYMBOLS ` .
45
56## 2.0.0
67- ** Breaking change** : Remove deprecated ` Monetize.extract_cents ` .
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ def to_big_decimal(value)
7575 def parse_currency
7676 computed_currency = nil
7777 computed_currency = input [ /[A-Z]{2,3}/ ]
78- computed_currency = nil unless Monetize :: Parser :: CURRENCY_SYMBOLS . value? ( computed_currency )
78+ computed_currency = nil unless Money :: Currency . find ( computed_currency )
7979 computed_currency ||= compute_currency if assume_from_symbol?
8080
8181 found = computed_currency || fallback_currency || Money . default_currency
Original file line number Diff line number Diff line change 118118
119119 it 'should use provided currency over symbol' do
120120 expect ( Monetize . parse ( '$1.05 CAD' ) ) . to eq Money . new ( 105 , 'CAD' )
121+ expect ( Monetize . parse ( '$1.05 DKK' ) ) . to eq Money . new ( 105 , 'DKK' )
121122 end
122123
123124 it 'ignores ZAR symbols that is part of a text' do
164165 end
165166
166167 context 'ISO code' do
167- it 'parses currency given as ISO code' do
168+ it 'parses currency in CURRENCY_SYMBOLS given as ISO code' do
168169 expect ( '20.00 USD' . to_money ) . to eq Money . new ( 20_00 , 'USD' )
169170 expect ( '20.00 EUR' . to_money ) . to eq Money . new ( 20_00 , 'EUR' )
170171 expect ( '20.00 GBP' . to_money ) . to eq Money . new ( 20_00 , 'GBP' )
171172 end
172173
174+ it 'parses currency not in CURRENCY_SYMBOLS given as ISO code' do
175+ expect ( Monetize ::Parser ::CURRENCY_SYMBOLS ) . to_not have_value ( 'DKK' )
176+ expect ( '20.00 DKK' . to_money ) . to eq Money . new ( 20_00 , 'DKK' )
177+ end
178+
173179 context 'with default currency' do
174180 before do
175181 Money . default_currency = Money ::Currency . new ( 'USD' )
You can’t perform that action at this time.
0 commit comments