unidom-order 1.5.4 → 1.5.5

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: fa820b20584f04de082fc98253ec9d5f390916db
4
- data.tar.gz: a224376ed7c857555400e2a8e251e600d14249f0
3
+ metadata.gz: 37f14a5fc4f78c947ea45ca34db35c679067e70b
4
+ data.tar.gz: c7e1a8e957fe3a99df0cb455395bb2024eb43569
5
5
  SHA512:
6
- metadata.gz: 29400ab1626f290b5d5b2446b169a73e83a2fdf5374ce4653848eb87f4f5d90bdb19a795c42a52494059e6bcfe4febbddaf272cdc0651e203e69cd905748bd30
7
- data.tar.gz: 94aa20d3f93e25f77f3b0002f17da8844cec6b33839bb360ba49f4152fa759d3d65756b6adc8418c51af20336d4f1693f0f71fb4bbe9f5ad4038197dc8eb9813
6
+ metadata.gz: 3b19a7210b00dd49b6075e127cf8e0fe1f72ac12f081581f19d3a0b870afae3e2e3694f8702ccf28ee9bc33f1f9e9461e0e7da3c45e931dab7c124ab312eb0d2
7
+ data.tar.gz: 44acfd90da53125b0884758d0f61b3a50c86fdf861b34c7f4327fbc0bf82e8aafa2662a8a73aafc503908bc98b4652b548ba2ee7a40adb3f27eab3d2ec0e1867
@@ -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: 1_000_000_000, greater_than: -1_000_000_000 }
11
+ validates :amount, presence: true, numericality: { greater_than_or_equal_to: -1_000_000_000, less_than_or_equal_to: 1_000_000_000 }
12
12
 
13
13
  belongs_to :adjusted, polymorphic: true
14
14
 
@@ -9,10 +9,10 @@ class Unidom::Order::OrderItem < Unidom::Order::ApplicationRecord
9
9
  include Unidom::Order::Concerns::AsAdjusted
10
10
 
11
11
  #validates :ordinal, presence: true, numericality: { only_integer: true, greater_than: 0, less_than: 1_000_000_000 }
12
- validates :unit_price, presence: true, numericality: { less_than: 1_000_000_000, greater_than: 0 }
13
- validates :quantity, presence: true, numericality: { less_than: 1_000_000_000, greater_than: 0 }
14
- validates :purchase_amount, presence: true, numericality: { less_than: 1_000_000_000, greater_than: 0 }
15
- validates :subtotal_amount, presence: true, numericality: { less_than: 1_000_000_000, greater_than: 0 }
12
+ validates :unit_price, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
13
+ validates :quantity, presence: true, numericality: { greater_than: 0, less_than_or_equal_to: 1_000_000_000 }
14
+ validates :purchase_amount, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
15
+ validates :subtotal_amount, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
16
16
 
17
17
  belongs_to :order, class_name: 'Unidom::Order::Order'
18
18
  belongs_to :ordered, polymorphic: true
@@ -18,33 +18,8 @@ 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
21
+ it_behaves_like 'validates numericality', model_attributes, :amount,
22
+ range: -1_000_000_000..1_000_000_000, minimum_inclusive: true, maximum_inclusive: true
48
23
 
49
24
  it_behaves_like 'ProgneTapera::EnumCode', described_class.new(model_attributes), :adjustment_factor, Unidom::Order::AdjustmentFactor
50
25
 
@@ -23,93 +23,14 @@ 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
26
+ it_behaves_like 'validates numericality', model_attributes, :unit_price,
27
+ range: 0..1_000_000_000, minimum_inclusive: true, maximum_inclusive: true
28
+ it_behaves_like 'validates numericality', model_attributes, :quantity,
29
+ range: 0..1_000_000_000, minimum_inclusive: false, maximum_inclusive: true
30
+ it_behaves_like 'validates numericality', model_attributes, :purchase_amount,
31
+ range: 0..1_000_000_000, minimum_inclusive: true, maximum_inclusive: true
32
+ it_behaves_like 'validates numericality', model_attributes, :subtotal_amount,
33
+ range: 0..1_000_000_000, minimum_inclusive: true, maximum_inclusive: true
113
34
 
114
35
  order_attributes = {
115
36
  placer_id: SecureRandom.uuid,
@@ -18,10 +18,9 @@ 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
-
23
21
  it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
24
22
 
23
+ number_length = described_class.columns_hash['number'].limit
25
24
  it_behaves_like 'validates', model_attributes, :number,
26
25
  { } => 0,
27
26
  { number: nil } => 2,
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Order
3
- VERSION = '1.5.4'.freeze
3
+ VERSION = '1.5.5'.freeze
4
4
  end
5
5
  end
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: 1.5.4
4
+ version: 1.5.5
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-17 00:00:00.000000000 Z
11
+ date: 2017-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common