shopify-money 0.11.4 → 0.11.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/money/deprecations.rb +1 -1
- data/lib/money/version.rb +1 -1
- data/lib/money_column/active_record_hooks.rb +3 -3
- data/spec/money_column_spec.rb +24 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9441b8dab64b7077e0d960f6a81dc069c283ac90
|
4
|
+
data.tar.gz: 3fddaf1c805956ee9ca67c9295047698dfeb19f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3c7e5ff1f9ac0a66bbcf0097f5cfdc5c7fa2b202d499850ab5c6620dcece9d96936c3b1e9a8abd6c387be910b8c92d7ef42263755752b4766dcedbac187546e
|
7
|
+
data.tar.gz: 36ac7078e3b1960f91d399517c468c29c62744a1068525c23263c4401ab075aae0be8c6e7f166e64050be2a1d6d78dfdcb3f26daab97000a97493a2e3bf41464
|
data/lib/money/deprecations.rb
CHANGED
@@ -8,7 +8,7 @@ Money.class_eval do
|
|
8
8
|
def self.deprecate(message)
|
9
9
|
if ACTIVE_SUPPORT_DEFINED
|
10
10
|
external_callstack = caller_locations.reject do |location|
|
11
|
-
location.to_s.include?('gems/money')
|
11
|
+
location.to_s.include?('gems/shopify-money')
|
12
12
|
end
|
13
13
|
active_support_deprecator.warn("[Shopify/Money] #{message}\n", external_callstack)
|
14
14
|
else
|
data/lib/money/version.rb
CHANGED
@@ -49,13 +49,13 @@ module MoneyColumn
|
|
49
49
|
end
|
50
50
|
|
51
51
|
currency_raw_source = options[:currency] || (send(options[:currency_column]) rescue nil)
|
52
|
-
currency_source = Money::Helpers.value_to_currency(currency_raw_source)
|
53
52
|
|
54
53
|
if !money.is_a?(Money)
|
55
|
-
return self[column] = Money.new(money,
|
54
|
+
return self[column] = Money.new(money, currency_raw_source).value
|
56
55
|
end
|
57
56
|
|
58
|
-
|
57
|
+
currency_source = currency_raw_source ? Money::Helpers.value_to_currency(currency_raw_source) : Money::NULL_CURRENCY
|
58
|
+
unless currency_source.compatible?(money.currency)
|
59
59
|
Money.deprecate("[money_column] currency mismatch between #{currency_source} and #{money.currency}.")
|
60
60
|
end
|
61
61
|
|
data/spec/money_column_spec.rb
CHANGED
@@ -367,4 +367,28 @@ RSpec.describe 'MoneyColumn' do
|
|
367
367
|
expect(MoneyClassInheritance2.instance_variable_get(:@money_column_options).keys).to_not include('prix')
|
368
368
|
end
|
369
369
|
end
|
370
|
+
|
371
|
+
describe 'default_currency = nil' do
|
372
|
+
around do |example|
|
373
|
+
default_currency = Money.default_currency
|
374
|
+
Money.default_currency = nil
|
375
|
+
example.run
|
376
|
+
Money.default_currency = default_currency
|
377
|
+
end
|
378
|
+
|
379
|
+
it 'writes currency from input value to the db' do
|
380
|
+
record.update(currency: nil)
|
381
|
+
record.update(price: Money.new(7, 'GBP'))
|
382
|
+
record.reload
|
383
|
+
expect(record.price.value).to eq(7)
|
384
|
+
expect(record.price.currency.to_s).to eq('GBP')
|
385
|
+
end
|
386
|
+
|
387
|
+
it 'raises missing currency error when input is not a money object' do
|
388
|
+
record.update(currency: nil)
|
389
|
+
|
390
|
+
expect { record.update(price: 3) }
|
391
|
+
.to raise_error(ArgumentError, 'missing currency')
|
392
|
+
end
|
393
|
+
end
|
370
394
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify-money
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|