Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Fix `Money::Currency.reset!` keeping the cached key set, so a currency registered before the reset was still accepted by `Money::Currency.new` and raised `NoMethodError` instead of `UnknownCurrency`
- Fix `Money::Bank::VariableExchange#import_rates` parsing `:json` with `JSON.load`, which instantiates any class named by a `json_class` key; it now uses `JSON.parse`

## 7.1.1
Expand Down
1 change: 1 addition & 0 deletions lib/money/currency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def each(&)
def reset!
@@instances = {}
@table = Loader.load_currencies
@stringified_keys = nil
clear_iso_numeric_cache
end

Expand Down
11 changes: 11 additions & 0 deletions spec/money/currency_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -533,5 +533,16 @@ def to_s
described_class.reset!
expect(described_class.find(:cad).decimal_mark).not_to eq modified_mark
end

it "drops a registered currency it no longer holds" do
described_class.register(iso_code: "ZZZ", subunit_to_unit: 100, priority: 1)
described_class.new("ZZZ")

described_class.reset!

expect(described_class.find(:zzz)).to be_nil
expect { described_class.new("ZZZ") }
.to raise_error(described_class::UnknownCurrency)
end
end
end