shopify-money 0.11.0 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 964eb834ae37a4f224f6ce79f5dcd75ae544d8a6
4
- data.tar.gz: 400e4c5737f8960c44ebb8d89b78f8fcc7506db2
3
+ metadata.gz: 3c62660129723a9f481f8221721c4da317b576a9
4
+ data.tar.gz: c70fd044ea5a5a1631c24b3725615fed02cf74b8
5
5
  SHA512:
6
- metadata.gz: 11c8e67a85e4709618df2f7443bd6102929e12883339fa8ad55ea7c9a2b2c3b951fe980250ef421b0b7d8066770eac6bad9fe6ea74493095722b00d610ae2b28
7
- data.tar.gz: 2b4abc9631217467ac967254cd41e5921635acacc351fd69d949fb51e342a6fe8bcf437a0c75d01b078dc5182bd598c157e5c7a1b3089df128832f648e93d4a6
6
+ metadata.gz: 8f8a19b78a2c33b5b0952d433e9d9d88f55fd7105c054478e51656a6137d935a92bf220309116960f08ac56392d3ff0fcf4dafdaafcb7d614874d3e442953bc2
7
+ data.tar.gz: 37f28f245c3ba5f4f1833f60981b1c0075f6391f2a88dbdae73ac489b37fdd4dc8c88c12f1ff25292489e58a065f25c29956ee58c7d61d4b5bf3fc85ba02b23c
data/lib/money/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Money
2
- VERSION = "0.11.0"
2
+ VERSION = "0.11.1"
3
3
  end
@@ -122,6 +122,11 @@ module MoneyColumn
122
122
  super(value)
123
123
  end
124
124
  end
125
+
126
+ def inherited(subclass)
127
+ subclass.instance_variable_set('@money_column_options', money_column_options.dup) if money_column_options
128
+ super
129
+ end
125
130
  end
126
131
  end
127
132
  end
@@ -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.0
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-20 00:00:00.000000000 Z
11
+ date: 2018-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler