shopify-money 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/money/version.rb +1 -1
- data/lib/money_column/active_record_hooks.rb +5 -0
- data/spec/money_column_spec.rb +29 -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: 3c62660129723a9f481f8221721c4da317b576a9
|
|
4
|
+
data.tar.gz: c70fd044ea5a5a1631c24b3725615fed02cf74b8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8f8a19b78a2c33b5b0952d433e9d9d88f55fd7105c054478e51656a6137d935a92bf220309116960f08ac56392d3ff0fcf4dafdaafcb7d614874d3e442953bc2
|
|
7
|
+
data.tar.gz: 37f28f245c3ba5f4f1833f60981b1c0075f6391f2a88dbdae73ac489b37fdd4dc8c88c12f1ff25292489e58a065f25c29956ee58c7d61d4b5bf3fc85ba02b23c
|
data/lib/money/version.rb
CHANGED
data/spec/money_column_spec.rb
CHANGED
|
@@ -49,6 +49,15 @@ class MoneyWithCustomAccessors < ActiveRecord::Base
|
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
+
class MoneyClassInheritance < MoneyWithCustomAccessors
|
|
53
|
+
money_column :prix, currency_column: 'currency'
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
class MoneyClassInheritance2 < MoneyWithCustomAccessors
|
|
57
|
+
money_column :price, currency: 'CAD'
|
|
58
|
+
money_column :price_usd, currency: 'USD'
|
|
59
|
+
end
|
|
60
|
+
|
|
52
61
|
RSpec.describe 'MoneyColumn' do
|
|
53
62
|
let(:amount) { 1.23 }
|
|
54
63
|
let(:currency) { 'EUR' }
|
|
@@ -321,4 +330,24 @@ RSpec.describe 'MoneyColumn' do
|
|
|
321
330
|
expect(object.instance_variable_get(:@money_column_cache)['price']).to eql(amount + 1)
|
|
322
331
|
end
|
|
323
332
|
end
|
|
333
|
+
|
|
334
|
+
describe 'class inheritance' do
|
|
335
|
+
it 'shares money columns declared on the parent class' do
|
|
336
|
+
expect(MoneyClassInheritance.instance_variable_get(:@money_column_options).dig('price', :currency_column)).to eq('currency')
|
|
337
|
+
expect(MoneyClassInheritance.instance_variable_get(:@money_column_options).dig('price', :currency)).to eq(nil)
|
|
338
|
+
expect(MoneyClassInheritance.new(price: Money.new(1, 'USD')).price).to eq(Money.new(2, 'USD'))
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
it 'subclass can define extra money columns' do
|
|
342
|
+
expect(MoneyClassInheritance.instance_variable_get(:@money_column_options).keys).to include('prix')
|
|
343
|
+
expect(MoneyClassInheritance.instance_variable_get(:@money_column_options).keys).to_not include('price_usd')
|
|
344
|
+
expect(MoneyClassInheritance.new(prix: Money.new(1, 'USD')).prix).to eq(Money.new(1, 'USD'))
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
it 'subclass can redefine money columns from parent' do
|
|
348
|
+
expect(MoneyClassInheritance2.instance_variable_get(:@money_column_options).dig('price', :currency)).to eq('CAD')
|
|
349
|
+
expect(MoneyClassInheritance2.instance_variable_get(:@money_column_options).dig('price', :currency_column)).to eq(nil)
|
|
350
|
+
expect(MoneyClassInheritance2.instance_variable_get(:@money_column_options).keys).to_not include('prix')
|
|
351
|
+
end
|
|
352
|
+
end
|
|
324
353
|
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.1
|
|
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-04-
|
|
11
|
+
date: 2018-04-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|