unidom-price 1.7.5 → 1.7.6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ecb6d6375efd70fbe8cd2303937b2a3c52f2a07
|
4
|
+
data.tar.gz: 592b4395a34337239111735e96ec33eb69223067
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2e6f359f6eec0cc267459e2f61f85eba04dd9b770179d535cfa3fee06ff04252f9239c43bf821bf7923150e946d4bf8fb58219b5852796d86e1fcafb53fec98
|
7
|
+
data.tar.gz: 0b2ad63cacb6b151c68b592d96690df561a65fc2201c59cb500236ca67f2a31ba3351c0452e03fcf31fc69f6d70411a12d0ef0db90e0e10a8bbb2e0d4448e39c
|
@@ -24,6 +24,14 @@ class Unidom::Price::Price < Unidom::Price::ApplicationRecord
|
|
24
24
|
##
|
25
25
|
# 将物品 priced 定价为 amount , 定价者是 pricer。
|
26
26
|
def self.price!(priced, amount: 0, pricer: nil, calculation_code: 'AMNT', pricing_code: 'BASE', charging_code: 'ONCE', opened_at: Time.now)
|
27
|
+
|
28
|
+
assert_present! :priced, priced
|
29
|
+
assert_present! :amount, amount
|
30
|
+
assert_present! :calculation_code, calculation_code
|
31
|
+
assert_present! :pricing_code, pricing_code
|
32
|
+
assert_present! :charging_code, charging_code
|
33
|
+
assert_present! :opened_at, opened_at
|
34
|
+
|
27
35
|
price = priced_is(priced).calculation_coded_as(calculation_code).pricing_coded_as(pricing_code).charging_coded_as(charging_code).valid_at.alive.first
|
28
36
|
if price.present?
|
29
37
|
price.amount = amount
|
@@ -10,9 +10,9 @@ shared_examples 'Unidom::Price::Concerns::AsPriced' do |model_attributes, pricer
|
|
10
10
|
|
11
11
|
context '#is_priced!' do
|
12
12
|
|
13
|
-
it 'should reject the amount argument = nil' do expect { @priced.is_priced! nil, by: pricer, at: Time.now }.to raise_error(ArgumentError, 'The amount argument is required.') end
|
14
|
-
it 'should reject the by argument = nil' do expect { @priced.is_priced! @amount, by: nil, at: Time.now }.to raise_error(ArgumentError, 'The by argument is required.') end
|
15
|
-
it 'should reject the at argument = nil' do expect { @priced.is_priced! @amount, by: pricer, at: nil }.to raise_error(ArgumentError, 'The at argument is required.') end
|
13
|
+
#it 'should reject the amount argument = nil' do expect { @priced.is_priced! nil, by: pricer, at: Time.now }.to raise_error(ArgumentError, 'The amount argument is required.') end
|
14
|
+
#it 'should reject the by argument = nil' do expect { @priced.is_priced! @amount, by: nil, at: Time.now }.to raise_error(ArgumentError, 'The by argument is required.') end
|
15
|
+
#it 'should reject the at argument = nil' do expect { @priced.is_priced! @amount, by: pricer, at: nil }.to raise_error(ArgumentError, 'The at argument is required.') end
|
16
16
|
|
17
17
|
it "should be able to be priced by #{pricer.inspect}" do
|
18
18
|
price = @priced.is_priced! @amount, by: pricer
|
@@ -32,7 +32,7 @@ shared_examples 'Unidom::Price::Concerns::AsPriced' do |model_attributes, pricer
|
|
32
32
|
|
33
33
|
context '#is_priced?' do
|
34
34
|
|
35
|
-
it 'should reject the at argument = nil' do expect { @priced.is_priced? at: nil }.to raise_error(ArgumentError, 'The at argument is required.') end
|
35
|
+
#it 'should reject the at argument = nil' do expect { @priced.is_priced? at: nil }.to raise_error(ArgumentError, 'The at argument is required.') end
|
36
36
|
|
37
37
|
it "should be able to be priced by #{pricer.inspect}" do
|
38
38
|
expect(@priced.is_priced?).to be_falsey
|
@@ -64,6 +64,11 @@ shared_examples 'Unidom::Price::Concerns::AsPriced' do |model_attributes, pricer
|
|
64
64
|
|
65
65
|
it_behaves_like 'has_many', model_attributes, :prices, Unidom::Price::Price, [ price_1_attribtues, price_2_attribtues ]
|
66
66
|
|
67
|
+
model = described_class.create! model_attributes
|
68
|
+
amount = 10.00
|
69
|
+
it_behaves_like 'assert_present!', model, :is_priced!, [ amount, { by: pricer, at: Time.now } ], [ { 0 => :amount }, :by, :at ]
|
70
|
+
it_behaves_like 'assert_present!', model, :is_priced?, [ { at: Time.now } ], [ :at ]
|
71
|
+
|
67
72
|
end
|
68
73
|
|
69
74
|
end
|
@@ -1,17 +1,21 @@
|
|
1
1
|
shared_examples 'Unidom::Price::Concerns::AsPricer' do |model_attributes|
|
2
2
|
|
3
|
-
|
4
|
-
priced_id: SecureRandom.uuid,
|
5
|
-
priced_type: 'Unidom::Price::Priced::Mock',
|
6
|
-
amount: 10.00
|
7
|
-
}
|
3
|
+
context do
|
8
4
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
price_1_attribtues = {
|
6
|
+
priced_id: SecureRandom.uuid,
|
7
|
+
priced_type: 'Unidom::Price::Priced::Mock',
|
8
|
+
amount: 10.00
|
9
|
+
}
|
14
10
|
|
15
|
-
|
11
|
+
price_2_attribtues = {
|
12
|
+
priced_id: SecureRandom.uuid,
|
13
|
+
priced_type: 'Unidom::Price::Priced::Mock',
|
14
|
+
amount: 21.00
|
15
|
+
}
|
16
|
+
|
17
|
+
it_behaves_like 'has_many', model_attributes, :pricings, Unidom::Price::Price, [ price_1_attribtues, price_2_attribtues ]
|
18
|
+
|
19
|
+
end
|
16
20
|
|
17
21
|
end
|
data/lib/unidom/price/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-price
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|