unidom-product 1.7.3 → 1.7.4

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: 45c80f934669ce3fa10183670be3001512c03d0c
4
- data.tar.gz: 47c73d4f27f96cdcfe84fccc66cdb1a09682f728
3
+ metadata.gz: 172e90aae1105935a4ac3c721620d615b99ad739
4
+ data.tar.gz: 4bfb57d960ca4e93aacdfb5b90f1f13ca1725761
5
5
  SHA512:
6
- metadata.gz: b484aecc01964febd43697a2728aeae4f4c3bee8fa49ad102eeb05c56bcdb8e725e0f39c032b32071d2f5839161c357fc2e887e83b26999420fe308094f4d9d0
7
- data.tar.gz: 272c521a7397b04298d6e0835be5a5955102866c95b99354207b248670ab42d7c0d0be5b758d5ca96c7af569ab0d0aef3c0dbbb57de796d4a4bcbad06ad4aac1
6
+ metadata.gz: 48d82e46e446bcfcb937a42c58666d297df4b5abb99bc11039119b53909b0f2f8c44f29274f2835452cd5739591317747cb11c96d86834becefe87b4ac287b46
7
+ data.tar.gz: ef3aee8a9fa7ea06ffdecbc5d33b10ee34f1a22ba2aa9203d5b794e690f10499247d440ddcad6576c11102ee304bc69ee9bf0e3f6d1e68b561aa4c828972579b
@@ -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, less_than: 1_000_000_000 }
21
+ validates :quantity, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 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,27 +18,8 @@ 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
21
+ it_behaves_like 'validates numericality', model_attributes, :quantity,
22
+ range: 0..1_000_000_000, minimum_inclusive: true, maximum_inclusive: true
42
23
 
43
24
  it_behaves_like 'ProgneTapera::EnumCode', described_class.new(model_attributes), :product_association, Unidom::Product::ProductAssociation
44
25
 
@@ -16,56 +16,16 @@ 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
-
24
19
  it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
25
20
 
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
21
+ it_behaves_like 'validates text', model_attributes, :name,
22
+ length: 2..described_class.columns_hash['name'].limit
23
+ it_behaves_like 'validates text', model_attributes, :abbreviation,
24
+ length: 1..described_class.columns_hash['abbreviation'].limit
25
+ it_behaves_like 'validates text', model_attributes, :measurement_unit,
26
+ length: 1..described_class.columns_hash['measurement_unit'].limit
27
+ it_behaves_like 'validates text', model_attributes, :packing_norm,
28
+ length: 1..described_class.columns_hash['packing_norm'].limit
69
29
 
70
30
  it_behaves_like 'ProgneTapera::EnumCode', described_class.new(model_attributes), :formset, Unidom::Product::Formset
71
31
 
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Product
3
- VERSION = '1.7.3'.freeze
3
+ VERSION = '1.7.4'.freeze
4
4
  end
5
5
  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: 1.7.3
4
+ version: 1.7.4
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-07 00:00:00.000000000 Z
11
+ date: 2017-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common