amountable 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -1
- data/amountable.gemspec +1 -1
- data/lib/amountable/version.rb +1 -1
- data/spec/amountable/amountable_spec.rb +28 -26
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c16626a30436789e2fd7b2f5ddf0b3a3a135b6f9
|
4
|
+
data.tar.gz: e5b5d6aacdc8a7d381ae87da6338030a086cd16f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e11a47ca33db3eda57f61a37b8f5ee362b4ee9dd8c38e289b3e8758517345e7e4a30a42d1c7b44dd6b7612150d61765e1667ee63ea92e082e01bf81034c327fc
|
7
|
+
data.tar.gz: 589b2f249b8d2f4466db720d3b5f60c3a1f0195b89a4a07a58c84b7c9bd6b54cf9a0790cd2a075ab38688c362522d11ae9f6621773545ca2f720ef173304da3b
|
data/.travis.yml
CHANGED
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.
|
22
|
+
gem.add_dependency 'activerecord-import', '~> 0.19.1'
|
23
23
|
gem.add_dependency 'money-rails'
|
24
24
|
gem.add_dependency 'monetize'
|
25
25
|
|
data/lib/amountable/version.rb
CHANGED
@@ -58,34 +58,36 @@ describe Amountable do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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(
|
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
|
+
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:
|
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.
|
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.
|
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.
|
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.
|