unidom-product 1.7 → 1.7.1
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: 72f86184228ad489bcee824496eb8ecf5e32920b
|
4
|
+
data.tar.gz: 61495f81ad2df7b6614f7111b96531dc06a87220
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60fc0f3e61219b39a3113ed173876966d43dbc3d7c37aae73a7f6ceeb94bc5d86fa73882beb9c12ed21c0f1d59b888031b846eef4d5771406aa9e6b7dc864697
|
7
|
+
data.tar.gz: fc7cb32d160b37a642e52507fa9979eb2e3a6eab49fe3cd9e390ce2e87de5890916184c746adf167d574eb32b6c89a67c54de70b1e168e57f68b66ac1f5176d9
|
@@ -18,7 +18,7 @@ class Unidom::Product::ProductAssociating < Unidom::Product::ApplicationRecord
|
|
18
18
|
include Unidom::Common::Concerns::ModelExtension
|
19
19
|
include ProgneTapera::EnumCode
|
20
20
|
|
21
|
-
validates :quantity, presence: true, numericality: { greater_than_or_equal_to: 0
|
21
|
+
validates :quantity, presence: true, numericality: { greater_than_or_equal_to: 0, less_than: 1_000_000_000 }
|
22
22
|
|
23
23
|
belongs_to :source, class_name: 'Unidom::Product::Product'
|
24
24
|
belongs_to :target, class_name: 'Unidom::Product::Product'
|
@@ -18,6 +18,30 @@ describe Unidom::Product::ProductAssociating, 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
|
+
|
43
|
+
it_behaves_like 'ProgneTapera::EnumCode', described_class.new(model_attributes), :product_association, Unidom::Product::ProductAssociation
|
44
|
+
|
21
45
|
end
|
22
46
|
|
23
47
|
end
|
@@ -16,8 +16,59 @@ describe Unidom::Product::Product, type: :model do
|
|
16
16
|
formset_code: 'WARE'
|
17
17
|
}
|
18
18
|
|
19
|
+
name_max_length = described_class.columns_hash['name'].limit
|
20
|
+
abbreviation_max_length = described_class.columns_hash['abbreviation'].limit
|
21
|
+
measurement_unit_max_length = described_class.columns_hash['measurement_unit'].limit
|
22
|
+
packing_norm_max_length = described_class.columns_hash['packing_norm'].limit
|
23
|
+
|
19
24
|
it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
|
20
25
|
|
26
|
+
it_behaves_like 'validates', model_attributes, :name,
|
27
|
+
{ } => 0,
|
28
|
+
{ name: nil } => 2,
|
29
|
+
{ name: '' } => 2,
|
30
|
+
{ name: 'A' } => 1,
|
31
|
+
{ name: 'AA' } => 0,
|
32
|
+
{ name: 'AAA' } => 0,
|
33
|
+
{ name: 'A'*(name_max_length-1) } => 0,
|
34
|
+
{ name: 'A'*name_max_length } => 0,
|
35
|
+
{ name: 'A'*(name_max_length+1) } => 1
|
36
|
+
|
37
|
+
it_behaves_like 'validates', model_attributes, :abbreviation,
|
38
|
+
{ } => 0,
|
39
|
+
{ abbreviation: nil } => 2,
|
40
|
+
{ abbreviation: '' } => 2,
|
41
|
+
{ abbreviation: 'A' } => 0,
|
42
|
+
{ abbreviation: 'AA' } => 0,
|
43
|
+
{ abbreviation: 'AAA' } => 0,
|
44
|
+
{ abbreviation: 'A'*(abbreviation_max_length-1) } => 0,
|
45
|
+
{ abbreviation: 'A'*abbreviation_max_length } => 0,
|
46
|
+
{ abbreviation: 'A'*(abbreviation_max_length+1) } => 1
|
47
|
+
|
48
|
+
it_behaves_like 'validates', model_attributes, :measurement_unit,
|
49
|
+
{ } => 0,
|
50
|
+
{ measurement_unit: nil } => 2,
|
51
|
+
{ measurement_unit: '' } => 2,
|
52
|
+
{ measurement_unit: 'A' } => 0,
|
53
|
+
{ measurement_unit: 'AA' } => 0,
|
54
|
+
{ measurement_unit: 'AAA' } => 0,
|
55
|
+
{ measurement_unit: 'A'*(measurement_unit_max_length-1) } => 0,
|
56
|
+
{ measurement_unit: 'A'*measurement_unit_max_length } => 0,
|
57
|
+
{ measurement_unit: 'A'*(measurement_unit_max_length+1) } => 1
|
58
|
+
|
59
|
+
it_behaves_like 'validates', model_attributes, :packing_norm,
|
60
|
+
{ } => 0,
|
61
|
+
{ packing_norm: nil } => 2,
|
62
|
+
{ packing_norm: '' } => 2,
|
63
|
+
{ packing_norm: 'A' } => 0,
|
64
|
+
{ packing_norm: 'AA' } => 0,
|
65
|
+
{ packing_norm: 'AAA' } => 0,
|
66
|
+
{ packing_norm: 'A'*(packing_norm_max_length-1) } => 0,
|
67
|
+
{ packing_norm: 'A'*packing_norm_max_length } => 0,
|
68
|
+
{ packing_norm: 'A'*(packing_norm_max_length+1) } => 1
|
69
|
+
|
70
|
+
it_behaves_like 'ProgneTapera::EnumCode', described_class.new(model_attributes), :formset, Unidom::Product::Formset
|
71
|
+
|
21
72
|
end
|
22
73
|
|
23
74
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-product
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.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-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|