unidom-order 1.5 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/app/models/unidom/order/order.rb +3 -3
- data/app/models/unidom/order/order_adjustment.rb +1 -1
- data/lib/rspec/models/unidom/order/order_adjustment_spec.rb +30 -0
- data/lib/rspec/models/unidom/order/order_item_spec.rb +88 -0
- data/lib/rspec/models/unidom/order/order_spec.rb +59 -0
- data/lib/unidom/order/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6658e1356ce649a6b3415a37cb0ca9fea5e5ffdb
|
4
|
+
data.tar.gz: a7179fba11b25779487bcd5113bd50fc25b574fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 397617eb953fadaeffc966b1124766aaeff8b80da21f4b01392ff248b922798d00c716e9e815202854914351a5b0546dda2b6764415310a41f60ac4d1ea1d73b
|
7
|
+
data.tar.gz: 36b6863723cc0de626cc4091253aed148e81237f2aa3fdb6607391b739edbaf7fb32cb6a0d4e9a4d97b6972267d94bc37a421a55a1318a1f18880644cf399835
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Unidom Order 订单领域模型引擎
|
2
2
|
|
3
|
+
[![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/unidom-order/frames)
|
3
4
|
[![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT)
|
5
|
+
|
4
6
|
[![Gem Version](https://badge.fury.io/rb/unidom-order.svg)](https://badge.fury.io/rb/unidom-order)
|
5
7
|
[![Dependency Status](https://gemnasium.com/badges/github.com/topbitdu/unidom-order.svg)](https://gemnasium.com/github.com/topbitdu/unidom-order)
|
6
8
|
|
@@ -8,9 +8,9 @@ class Unidom::Order::Order < Unidom::Order::ApplicationRecord
|
|
8
8
|
include Unidom::Common::Concerns::ModelExtension
|
9
9
|
include Unidom::Order::Concerns::AsAdjusted
|
10
10
|
|
11
|
-
validates :number, presence: true, length: { is: self.columns_hash['number'].limit
|
12
|
-
validates :purchase_amount, presence: true, numericality: { less_than:
|
13
|
-
validates :aggregate_amount, presence: true, numericality: { less_than:
|
11
|
+
validates :number, presence: true, length: { is: self.columns_hash['number'].limit }
|
12
|
+
validates :purchase_amount, presence: true, numericality: { less_than: 1_000_000_000, greater_than: 0 }
|
13
|
+
validates :aggregate_amount, presence: true, numericality: { less_than: 1_000_000_000, greater_than: 0 }
|
14
14
|
|
15
15
|
belongs_to :placer, polymorphic: true
|
16
16
|
belongs_to :taker, polymorphic: true
|
@@ -8,7 +8,7 @@ class Unidom::Order::OrderAdjustment < Unidom::Order::ApplicationRecord
|
|
8
8
|
include Unidom::Common::Concerns::ModelExtension
|
9
9
|
include ProgneTapera::EnumCode
|
10
10
|
|
11
|
-
validates :amount, presence: true, numericality: { less_than:
|
11
|
+
validates :amount, presence: true, numericality: { less_than: 1_000_000_000, greater_than: -1_000_000_000 }
|
12
12
|
|
13
13
|
belongs_to :adjusted, polymorphic: true
|
14
14
|
|
@@ -18,6 +18,36 @@ describe Unidom::Order::OrderAdjustment, type: :model do
|
|
18
18
|
|
19
19
|
it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
|
20
20
|
|
21
|
+
it_behaves_like 'validates', model_attributes, :amount,
|
22
|
+
{ } => 0,
|
23
|
+
{ amount: nil } => 2,
|
24
|
+
{ amount: '' } => 2,
|
25
|
+
{ amount: '1' } => 0,
|
26
|
+
{ amount: 1 } => 0,
|
27
|
+
{ amount: 'A' } => 1,
|
28
|
+
{ amount: '1.23' } => 0,
|
29
|
+
{ amount: 1.23 } => 0,
|
30
|
+
{ amount: '-0.01' } => 0,
|
31
|
+
{ amount: -0.01 } => 0,
|
32
|
+
{ amount: '0' } => 0,
|
33
|
+
{ amount: 0 } => 0,
|
34
|
+
{ amount: '0.01' } => 0,
|
35
|
+
{ amount: 0.01 } => 0,
|
36
|
+
{ amount: '999_999_999.99' } => 0,
|
37
|
+
{ amount: 999_999_999.99 } => 0,
|
38
|
+
{ amount: '1_000_000_000' } => 1,
|
39
|
+
{ amount: 1_000_000_000 } => 1,
|
40
|
+
{ amount: '1_000_000_000.01' } => 1,
|
41
|
+
{ amount: 1_000_000_000.01 } => 1,
|
42
|
+
{ amount: '-999_999_999.99' } => 0,
|
43
|
+
{ amount: -999_999_999.99 } => 0,
|
44
|
+
{ amount: '-1_000_000_000' } => 1,
|
45
|
+
{ amount: -1_000_000_000 } => 1,
|
46
|
+
{ amount: '-1_000_000_000.01' } => 1,
|
47
|
+
{ amount: -1_000_000_000.01 } => 1
|
48
|
+
|
49
|
+
it_behaves_like 'ProgneTapera::EnumCode', described_class.new(model_attributes), :adjustment_factor, Unidom::Order::AdjustmentFactor
|
50
|
+
|
21
51
|
end
|
22
52
|
|
23
53
|
end
|
@@ -23,6 +23,94 @@ describe Unidom::Order::OrderItem, type: :model do
|
|
23
23
|
|
24
24
|
it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
|
25
25
|
|
26
|
+
it_behaves_like 'validates', model_attributes, :unit_price,
|
27
|
+
{ } => 0,
|
28
|
+
{ unit_price: nil } => 2,
|
29
|
+
{ unit_price: '' } => 2,
|
30
|
+
{ unit_price: '1' } => 0,
|
31
|
+
{ unit_price: 1 } => 0,
|
32
|
+
{ unit_price: 'A' } => 1,
|
33
|
+
{ unit_price: '1.23' } => 0,
|
34
|
+
{ unit_price: 1.23 } => 0,
|
35
|
+
{ unit_price: '-0.01' } => 1,
|
36
|
+
{ unit_price: -0.01 } => 1,
|
37
|
+
{ unit_price: '0' } => 1,
|
38
|
+
{ unit_price: 0 } => 1,
|
39
|
+
{ unit_price: '0.01' } => 0,
|
40
|
+
{ unit_price: 0.01 } => 0,
|
41
|
+
{ unit_price: '999_999_999.99' } => 0,
|
42
|
+
{ unit_price: 999_999_999.99 } => 0,
|
43
|
+
{ unit_price: '1_000_000_000' } => 1,
|
44
|
+
{ unit_price: 1_000_000_000 } => 1,
|
45
|
+
{ unit_price: '1_000_000_000.01' } => 1,
|
46
|
+
{ unit_price: 1_000_000_000.01 } => 1
|
47
|
+
|
48
|
+
it_behaves_like 'validates', model_attributes, :quantity,
|
49
|
+
{ } => 0,
|
50
|
+
{ quantity: nil } => 2,
|
51
|
+
{ quantity: '' } => 2,
|
52
|
+
{ quantity: '1' } => 0,
|
53
|
+
{ quantity: 1 } => 0,
|
54
|
+
{ quantity: 'A' } => 1,
|
55
|
+
{ quantity: '1.23' } => 0,
|
56
|
+
{ quantity: 1.23 } => 0,
|
57
|
+
{ quantity: '-0.01' } => 1,
|
58
|
+
{ quantity: -0.01 } => 1,
|
59
|
+
{ quantity: '0' } => 1,
|
60
|
+
{ quantity: 0 } => 1,
|
61
|
+
{ quantity: '0.01' } => 0,
|
62
|
+
{ quantity: 0.01 } => 0,
|
63
|
+
{ quantity: '999_999_999.99' } => 0,
|
64
|
+
{ quantity: 999_999_999.99 } => 0,
|
65
|
+
{ quantity: '1_000_000_000' } => 1,
|
66
|
+
{ quantity: 1_000_000_000 } => 1,
|
67
|
+
{ quantity: '1_000_000_000.01' } => 1,
|
68
|
+
{ quantity: 1_000_000_000.01 } => 1
|
69
|
+
|
70
|
+
it_behaves_like 'validates', model_attributes, :purchase_amount,
|
71
|
+
{ } => 0,
|
72
|
+
{ purchase_amount: nil } => 2,
|
73
|
+
{ purchase_amount: '' } => 2,
|
74
|
+
{ purchase_amount: '1' } => 0,
|
75
|
+
{ purchase_amount: 1 } => 0,
|
76
|
+
{ purchase_amount: 'A' } => 1,
|
77
|
+
{ purchase_amount: '1.23' } => 0,
|
78
|
+
{ purchase_amount: 1.23 } => 0,
|
79
|
+
{ purchase_amount: '-0.01' } => 1,
|
80
|
+
{ purchase_amount: -0.01 } => 1,
|
81
|
+
{ purchase_amount: '0' } => 1,
|
82
|
+
{ purchase_amount: 0 } => 1,
|
83
|
+
{ purchase_amount: '0.01' } => 0,
|
84
|
+
{ purchase_amount: 0.01 } => 0,
|
85
|
+
{ purchase_amount: '999_999_999.99' } => 0,
|
86
|
+
{ purchase_amount: 999_999_999.99 } => 0,
|
87
|
+
{ purchase_amount: '1_000_000_000' } => 1,
|
88
|
+
{ purchase_amount: 1_000_000_000 } => 1,
|
89
|
+
{ purchase_amount: '1_000_000_000.01' } => 1,
|
90
|
+
{ purchase_amount: 1_000_000_000.01 } => 1
|
91
|
+
|
92
|
+
it_behaves_like 'validates', model_attributes, :subtotal_amount,
|
93
|
+
{ } => 0,
|
94
|
+
{ subtotal_amount: nil } => 2,
|
95
|
+
{ subtotal_amount: '' } => 2,
|
96
|
+
{ subtotal_amount: '1' } => 0,
|
97
|
+
{ subtotal_amount: 1 } => 0,
|
98
|
+
{ subtotal_amount: 'A' } => 1,
|
99
|
+
{ subtotal_amount: '1.23' } => 0,
|
100
|
+
{ subtotal_amount: 1.23 } => 0,
|
101
|
+
{ subtotal_amount: '-0.01' } => 1,
|
102
|
+
{ subtotal_amount: -0.01 } => 1,
|
103
|
+
{ subtotal_amount: '0' } => 1,
|
104
|
+
{ subtotal_amount: 0 } => 1,
|
105
|
+
{ subtotal_amount: '0.01' } => 0,
|
106
|
+
{ subtotal_amount: 0.01 } => 0,
|
107
|
+
{ subtotal_amount: '999_999_999.99' } => 0,
|
108
|
+
{ subtotal_amount: 999_999_999.99 } => 0,
|
109
|
+
{ subtotal_amount: '1_000_000_000' } => 1,
|
110
|
+
{ subtotal_amount: 1_000_000_000 } => 1,
|
111
|
+
{ subtotal_amount: '1_000_000_000.01' } => 1,
|
112
|
+
{ subtotal_amount: 1_000_000_000.01 } => 1
|
113
|
+
|
26
114
|
end
|
27
115
|
|
28
116
|
end
|
@@ -18,8 +18,67 @@ describe Unidom::Order::Order, type: :model do
|
|
18
18
|
aggregate_amount: 12.00
|
19
19
|
}
|
20
20
|
|
21
|
+
number_length = described_class.columns_hash['number'].limit
|
22
|
+
|
21
23
|
it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
|
22
24
|
|
25
|
+
it_behaves_like 'validates', model_attributes, :number,
|
26
|
+
{ } => 0,
|
27
|
+
{ number: nil } => 2,
|
28
|
+
{ number: '' } => 2,
|
29
|
+
{ number: '1' } => 1,
|
30
|
+
{ number: 'A' } => 1,
|
31
|
+
{ number: '9'*(number_length-1) } => 1,
|
32
|
+
{ number: 'A'*(number_length-1) } => 1,
|
33
|
+
{ number: '9'*number_length } => 0,
|
34
|
+
{ number: 'A'*number_length } => 0,
|
35
|
+
{ number: '9'*(number_length+1) } => 1,
|
36
|
+
{ number: 'A'*(number_length+1) } => 1
|
37
|
+
|
38
|
+
it_behaves_like 'validates', model_attributes, :purchase_amount,
|
39
|
+
{ } => 0,
|
40
|
+
{ purchase_amount: nil } => 2,
|
41
|
+
{ purchase_amount: '' } => 2,
|
42
|
+
{ purchase_amount: '1' } => 0,
|
43
|
+
{ purchase_amount: 1 } => 0,
|
44
|
+
{ purchase_amount: 'A' } => 1,
|
45
|
+
{ purchase_amount: '1.23' } => 0,
|
46
|
+
{ purchase_amount: 1.23 } => 0,
|
47
|
+
{ purchase_amount: '-0.01' } => 1,
|
48
|
+
{ purchase_amount: -0.01 } => 1,
|
49
|
+
{ purchase_amount: '0' } => 1,
|
50
|
+
{ purchase_amount: 0 } => 1,
|
51
|
+
{ purchase_amount: '0.01' } => 0,
|
52
|
+
{ purchase_amount: 0.01 } => 0,
|
53
|
+
{ purchase_amount: '999_999_999.99' } => 0,
|
54
|
+
{ purchase_amount: 999_999_999.99 } => 0,
|
55
|
+
{ purchase_amount: '1_000_000_000' } => 1,
|
56
|
+
{ purchase_amount: 1_000_000_000 } => 1,
|
57
|
+
{ purchase_amount: '1_000_000_000.01' } => 1,
|
58
|
+
{ purchase_amount: 1_000_000_000.01 } => 1
|
59
|
+
|
60
|
+
it_behaves_like 'validates', model_attributes, :aggregate_amount,
|
61
|
+
{ } => 0,
|
62
|
+
{ aggregate_amount: nil } => 2,
|
63
|
+
{ aggregate_amount: '' } => 2,
|
64
|
+
{ aggregate_amount: '1' } => 0,
|
65
|
+
{ aggregate_amount: 1 } => 0,
|
66
|
+
{ aggregate_amount: 'A' } => 1,
|
67
|
+
{ aggregate_amount: '1.23' } => 0,
|
68
|
+
{ aggregate_amount: 1.23 } => 0,
|
69
|
+
{ aggregate_amount: '-0.01' } => 1,
|
70
|
+
{ aggregate_amount: -0.01 } => 1,
|
71
|
+
{ aggregate_amount: '0' } => 1,
|
72
|
+
{ aggregate_amount: 0 } => 1,
|
73
|
+
{ aggregate_amount: '0.01' } => 0,
|
74
|
+
{ aggregate_amount: 0.01 } => 0,
|
75
|
+
{ aggregate_amount: '999_999_999.99' } => 0,
|
76
|
+
{ aggregate_amount: 999_999_999.99 } => 0,
|
77
|
+
{ aggregate_amount: '1_000_000_000' } => 1,
|
78
|
+
{ aggregate_amount: 1_000_000_000 } => 1,
|
79
|
+
{ aggregate_amount: '1_000_000_000.01' } => 1,
|
80
|
+
{ aggregate_amount: 1_000_000_000.01 } => 1
|
81
|
+
|
23
82
|
end
|
24
83
|
|
25
84
|
end
|
data/lib/unidom/order/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-order
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.5.1
|
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-02-
|
11
|
+
date: 2017-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|