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: 2a61dafa0005f117a0f8a4399db39e38b378d0dd
4
- data.tar.gz: 944c6ec8824681f2017b5d695b6d0730ea1225dc
3
+ metadata.gz: 5ecb6d6375efd70fbe8cd2303937b2a3c52f2a07
4
+ data.tar.gz: 592b4395a34337239111735e96ec33eb69223067
5
5
  SHA512:
6
- metadata.gz: 151fe246663561bab24cb12ec9b8c7d5930e560a971f64f5842dee93f7c2db964f9cce6762de64be3289d633c7752cf42a92d91668474c779846276969383382
7
- data.tar.gz: b10a1c96510d2fbf28db596b2d4e4b2012f248727999b6c58533e23250b191cdcb58f654c87a0340419c8136b1136caca705bd5003b0f0a27f085b66e44cb874
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
- price_1_attribtues = {
4
- priced_id: SecureRandom.uuid,
5
- priced_type: 'Unidom::Price::Priced::Mock',
6
- amount: 10.00
7
- }
3
+ context do
8
4
 
9
- price_2_attribtues = {
10
- priced_id: SecureRandom.uuid,
11
- priced_type: 'Unidom::Price::Priced::Mock',
12
- amount: 21.00
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
- it_behaves_like 'has_many', model_attributes, :pricings, Unidom::Price::Price, [ price_1_attribtues, price_2_attribtues ]
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
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Price
3
- VERSION = '1.7.5'.freeze
3
+ VERSION = '1.7.6'.freeze
4
4
  end
5
5
  end
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.5
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-03-24 00:00:00.000000000 Z
11
+ date: 2017-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common