amountable 0.2.4 → 0.2.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c37c1a1882d94206f8154a689c1055bc026e854
4
- data.tar.gz: 15766a308868b41811f11b4d5d6912b10ab1319b
3
+ metadata.gz: c16626a30436789e2fd7b2f5ddf0b3a3a135b6f9
4
+ data.tar.gz: e5b5d6aacdc8a7d381ae87da6338030a086cd16f
5
5
  SHA512:
6
- metadata.gz: e60727be4b0b233bec117154cbb8b1cd52d5851a6afd55b27a55ba5c8a6547dee5b16f2e77ef301db6407749e2fd53911786072e00bd5bdd545933d33a08a667
7
- data.tar.gz: 0a7dc794e917cca74ec4d1087071a482dd6013f5d8c6c401e8662c607b8811788409e7035ec5edc6e7fbf0347c30191c6c4117a7dd74ac7eda8d526502001d4c
6
+ metadata.gz: e11a47ca33db3eda57f61a37b8f5ee362b4ee9dd8c38e289b3e8758517345e7e4a30a42d1c7b44dd6b7612150d61765e1667ee63ea92e082e01bf81034c327fc
7
+ data.tar.gz: 589b2f249b8d2f4466db720d3b5f60c3a1f0195b89a4a07a58c84b7c9bd6b54cf9a0790cd2a075ab38688c362522d11ae9f6621773545ca2f720ef173304da3b
data/.travis.yml CHANGED
@@ -1,3 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2
3
+ - 2.2.2
4
+ addons:
5
+ postgresql: "9.4"
data/amountable.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
19
19
 
20
20
  gem.add_dependency 'activerecord', '>= 4.1', '< 5.1'
21
21
  gem.add_dependency 'activesupport', '>= 4.1', '< 5.1'
22
- gem.add_dependency 'activerecord-import', '~> 0.15.0'
22
+ gem.add_dependency 'activerecord-import', '~> 0.19.1'
23
23
  gem.add_dependency 'money-rails'
24
24
  gem.add_dependency 'monetize'
25
25
 
@@ -1,5 +1,5 @@
1
1
  # Copyright 2015-2016, Instacart
2
2
 
3
3
  module Amountable
4
- VERSION = '0.2.4'
4
+ VERSION = '0.2.5'
5
5
  end
@@ -58,34 +58,36 @@ describe Amountable do
58
58
  end
59
59
  end
60
60
 
61
- context 'storage == :jsonb' do
62
- it 'should' do
63
- subscription = Subscription.new
64
- expect { subscription.save }.not_to change { Amountable::Amount.count }
65
- expect(subscription.amounts).to eq(Set.new)
66
- expect(subscription.attributes['amounts']).to be_nil
67
- %i(sub_total taxes total).each do |name|
68
- expect(subscription.send(name)).to eq(Money.zero)
69
- end
70
- subscription.sub_total = Money.new(100)
71
- expect(subscription.sub_total).to eq(Money.new(100))
72
- expect(subscription.attributes['amounts']).to eq({'amounts' => {'sub_total' => {'cents' => 100, 'currency' => 'USD'}}, 'sets' => {'total' => {'cents' => 100, 'currency' => 'USD'}}})
73
- expect(subscription.total).to eq(Money.new(100))
74
- expect(subscription.amounts.size).to eq(1)
75
- subscription.amounts.first.tap do |amount|
76
- expect(amount.name).to eq('sub_total')
77
- expect(amount.value).to eq(Money.new(100))
78
- expect(amount.new_record?).to be true
61
+ if jsonb_available?
62
+ context 'storage == :jsonb' do
63
+ it 'should' do
64
+ subscription = Subscription.new
79
65
  expect { subscription.save }.not_to change { Amountable::Amount.count }
80
- expect(amount.persisted?).to be false
66
+ expect(subscription.amounts).to eq(Set.new)
67
+ expect(subscription.attributes['amounts']).to be_nil
68
+ %i(sub_total taxes total).each do |name|
69
+ expect(subscription.send(name)).to eq(Money.zero)
70
+ end
71
+ subscription.sub_total = Money.new(100)
72
+ expect(subscription.sub_total).to eq(Money.new(100))
73
+ expect(subscription.attributes['amounts']).to eq({'amounts' => {'sub_total' => {'cents' => 100, 'currency' => 'USD'}}, 'sets' => {'total' => {'cents' => 100, 'currency' => 'USD'}}})
74
+ expect(subscription.total).to eq(Money.new(100))
75
+ expect(subscription.amounts.size).to eq(1)
76
+ subscription.amounts.first.tap do |amount|
77
+ expect(amount.name).to eq('sub_total')
78
+ expect(amount.value).to eq(Money.new(100))
79
+ expect(amount.new_record?).to be true
80
+ expect { subscription.save }.not_to change { Amountable::Amount.count }
81
+ expect(amount.persisted?).to be false
82
+ end
83
+ subscription.update_attributes(sub_total: Money.new(200))
84
+ expect(subscription.sub_total).to eq(Money.new(200))
85
+ expect(subscription.total).to eq(Money.new(200))
86
+ subscription.sub_total = Money.zero
87
+ expect(subscription.sub_total).to eq(Money.zero)
88
+ expect(subscription.total).to eq(Money.zero)
89
+ expect(subscription.attributes['amounts']).to eq({'amounts' => {}, 'sets' => {}})
81
90
  end
82
- subscription.update_attributes(sub_total: Money.new(200))
83
- expect(subscription.sub_total).to eq(Money.new(200))
84
- expect(subscription.total).to eq(Money.new(200))
85
- subscription.sub_total = Money.zero
86
- expect(subscription.sub_total).to eq(Money.zero)
87
- expect(subscription.total).to eq(Money.zero)
88
- expect(subscription.attributes['amounts']).to eq({'amounts' => {}, 'sets' => {}})
89
91
  end
90
92
  end
91
93
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amountable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emmanuel Turlay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-02 00:00:00.000000000 Z
11
+ date: 2017-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -56,14 +56,14 @@ dependencies:
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: 0.15.0
59
+ version: 0.19.1
60
60
  type: :runtime
61
61
  prerelease: false
62
62
  version_requirements: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: 0.15.0
66
+ version: 0.19.1
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: money-rails
69
69
  requirement: !ruby/object:Gem::Requirement
@@ -244,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
244
244
  version: '0'
245
245
  requirements: []
246
246
  rubyforge_project:
247
- rubygems_version: 2.4.5
247
+ rubygems_version: 2.5.2
248
248
  signing_key:
249
249
  specification_version: 4
250
250
  summary: Easy Money fields for your Rails models.