unidom-shipment 0.7 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/unidom/shipment/shipment.rb +2 -2
- data/app/models/unidom/shipment/shipment_item.rb +1 -1
- data/lib/rspec/models/unidom/shipment/shipment_item_spec.rb +22 -0
- data/lib/rspec/models/unidom/shipment/shipment_spec.rb +44 -0
- data/lib/unidom/shipment/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: 304fce67cb953e5e289da4c1cf6c42b5c82e7947
|
4
|
+
data.tar.gz: c98001c62b9e41af1b63615cf7dfe8f821f2fb55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebdcefe467d66d4dcc27b9132e8e318f36b79a6a7efdaf30c86e126bb643f72c8908150b90ecbb5b4d5e76a138690a3fe47977d4ef615a421df50efc437e165e
|
7
|
+
data.tar.gz: f084c2b3c58493e4c458634a4f761654a390a3c9b852b5e318d5f93464c0539b41a54875383a13c7e8e5282c1f3ce9e009cbb1a81799fa663f074565de7ce547
|
@@ -8,8 +8,8 @@ class Unidom::Shipment::Shipment < Unidom::Shipment::ApplicationRecord
|
|
8
8
|
include Unidom::Common::Concerns::ModelExtension
|
9
9
|
include ProgneTapera::EnumCode
|
10
10
|
|
11
|
-
validates :estimated_amount, presence: true, numericality: { greater_than_or_equal_to: 0 }
|
12
|
-
validates :actual_amount, presence: true, numericality: { greater_than_or_equal_to: 0 }
|
11
|
+
validates :estimated_amount, presence: true, numericality: { greater_than_or_equal_to: 0, less_than: 1_000_000_000 }
|
12
|
+
validates :actual_amount, presence: true, numericality: { greater_than_or_equal_to: 0, less_than: 1_000_000_000 }
|
13
13
|
|
14
14
|
belongs_to :sender_party, polymorphic: true
|
15
15
|
belongs_to :sender_agent, polymorphic: true
|
@@ -7,7 +7,7 @@ class Unidom::Shipment::ShipmentItem < Unidom::Shipment::ApplicationRecord
|
|
7
7
|
|
8
8
|
include Unidom::Common::Concerns::ModelExtension
|
9
9
|
|
10
|
-
validates :quantity, presence: true, numericality: { greater_than_or_equal_to: 0 }
|
10
|
+
validates :quantity, presence: true, numericality: { greater_than_or_equal_to: 0, less_than: 1_000_000_000 }
|
11
11
|
|
12
12
|
belongs_to :shipment, class_name: 'Unidom::Shipment::Shipment'
|
13
13
|
belongs_to :shipped, polymorphic: true
|
@@ -18,6 +18,28 @@ describe Unidom::Shipment::ShipmentItem, 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, :quantity,
|
22
|
+
{ } => 0,
|
23
|
+
{ quantity: nil } => 2,
|
24
|
+
{ quantity: '' } => 2,
|
25
|
+
{ quantity: '1' } => 0,
|
26
|
+
{ quantity: 1 } => 0,
|
27
|
+
{ quantity: 'A' } => 1,
|
28
|
+
{ quantity: '1.23' } => 0,
|
29
|
+
{ quantity: 1.23 } => 0,
|
30
|
+
{ quantity: '-0.01' } => 1,
|
31
|
+
{ quantity: -0.01 } => 1,
|
32
|
+
{ quantity: '0' } => 0,
|
33
|
+
{ quantity: 0 } => 0,
|
34
|
+
{ quantity: '0.01' } => 0,
|
35
|
+
{ quantity: 0.01 } => 0,
|
36
|
+
{ quantity: '999_999_999.99' } => 0,
|
37
|
+
{ quantity: 999_999_999.99 } => 0,
|
38
|
+
{ quantity: '1_000_000_000' } => 1,
|
39
|
+
{ quantity: 1_000_000_000 } => 1,
|
40
|
+
{ quantity: '1_000_000_000.01' } => 1,
|
41
|
+
{ quantity: 1_000_000_000.01 } => 1
|
42
|
+
|
21
43
|
end
|
22
44
|
|
23
45
|
end
|
@@ -39,6 +39,50 @@ describe Unidom::Shipment::Shipment, type: :model do
|
|
39
39
|
|
40
40
|
it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
|
41
41
|
|
42
|
+
it_behaves_like 'validates', model_attributes, :estimated_amount,
|
43
|
+
{ } => 0,
|
44
|
+
{ estimated_amount: nil } => 2,
|
45
|
+
{ estimated_amount: '' } => 2,
|
46
|
+
{ estimated_amount: '1' } => 0,
|
47
|
+
{ estimated_amount: 1 } => 0,
|
48
|
+
{ estimated_amount: 'A' } => 1,
|
49
|
+
{ estimated_amount: '1.23' } => 0,
|
50
|
+
{ estimated_amount: 1.23 } => 0,
|
51
|
+
{ estimated_amount: '-0.01' } => 1,
|
52
|
+
{ estimated_amount: -0.01 } => 1,
|
53
|
+
{ estimated_amount: '0' } => 0,
|
54
|
+
{ estimated_amount: 0 } => 0,
|
55
|
+
{ estimated_amount: '0.01' } => 0,
|
56
|
+
{ estimated_amount: 0.01 } => 0,
|
57
|
+
{ estimated_amount: '999_999_999.99' } => 0,
|
58
|
+
{ estimated_amount: 999_999_999.99 } => 0,
|
59
|
+
{ estimated_amount: '1_000_000_000' } => 1,
|
60
|
+
{ estimated_amount: 1_000_000_000 } => 1,
|
61
|
+
{ estimated_amount: '1_000_000_000.01' } => 1,
|
62
|
+
{ estimated_amount: 1_000_000_000.01 } => 1
|
63
|
+
|
64
|
+
it_behaves_like 'validates', model_attributes, :actual_amount,
|
65
|
+
{ } => 0,
|
66
|
+
{ actual_amount: nil } => 2,
|
67
|
+
{ actual_amount: '' } => 2,
|
68
|
+
{ actual_amount: '1' } => 0,
|
69
|
+
{ actual_amount: 1 } => 0,
|
70
|
+
{ actual_amount: 'A' } => 1,
|
71
|
+
{ actual_amount: '1.23' } => 0,
|
72
|
+
{ actual_amount: 1.23 } => 0,
|
73
|
+
{ actual_amount: '-0.01' } => 1,
|
74
|
+
{ actual_amount: -0.01 } => 1,
|
75
|
+
{ actual_amount: '0' } => 0,
|
76
|
+
{ actual_amount: 0 } => 0,
|
77
|
+
{ actual_amount: '0.01' } => 0,
|
78
|
+
{ actual_amount: 0.01 } => 0,
|
79
|
+
{ actual_amount: '999_999_999.99' } => 0,
|
80
|
+
{ actual_amount: 999_999_999.99 } => 0,
|
81
|
+
{ actual_amount: '1_000_000_000' } => 1,
|
82
|
+
{ actual_amount: 1_000_000_000 } => 1,
|
83
|
+
{ actual_amount: '1_000_000_000.01' } => 1,
|
84
|
+
{ actual_amount: 1_000_000_000.01 } => 1
|
85
|
+
|
42
86
|
end
|
43
87
|
|
44
88
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-shipment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.7.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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|