unidom-order 1.5.3 → 1.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47c98786e6271f1089c7b6496ffdabfe5e025bbb
4
- data.tar.gz: b70f21a33fa5b80d831e2ce69fafa5ed13f31f86
3
+ metadata.gz: fa820b20584f04de082fc98253ec9d5f390916db
4
+ data.tar.gz: a224376ed7c857555400e2a8e251e600d14249f0
5
5
  SHA512:
6
- metadata.gz: 986bd454ecd0d4d8235efc213baa888a016d9bb0ba110dc0be5b0c4f19c240ef19780ce53d670a218cc0270d09090022572a5fc1c4975c5210b8b97bc7bb6808
7
- data.tar.gz: bc6b8da172abb251afb8800dbfc2bc6d53307a71fdac6a5fdbb0e66e96e9e05e8a096808427fcc31187def45e98ebaf99fe09103572b8033ade8288a64663ca3
6
+ metadata.gz: 29400ab1626f290b5d5b2446b169a73e83a2fdf5374ce4653848eb87f4f5d90bdb19a795c42a52494059e6bcfe4febbddaf272cdc0651e203e69cd905748bd30
7
+ data.tar.gz: 94aa20d3f93e25f77f3b0002f17da8844cec6b33839bb360ba49f4152fa759d3d65756b6adc8418c51af20336d4f1693f0f71fb4bbe9f5ad4038197dc8eb9813
@@ -9,8 +9,8 @@ class Unidom::Order::Order < Unidom::Order::ApplicationRecord
9
9
  include Unidom::Order::Concerns::AsAdjusted
10
10
 
11
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 }
12
+ validates :purchase_amount, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
13
+ validates :aggregate_amount, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
14
14
 
15
15
  belongs_to :placer, polymorphic: true
16
16
  belongs_to :taker, polymorphic: true
@@ -74,6 +74,8 @@ describe Unidom::Order::OrderAdjustment, type: :model do
74
74
  it_behaves_like 'belongs_to', model_attributes, :adjusted, Unidom::Order::Order, order_attributes
75
75
  it_behaves_like 'belongs_to', model_attributes, :adjusted, Unidom::Order::OrderItem, order_item_attributes
76
76
 
77
+ it_behaves_like 'polymorphic scope', model_attributes, :adjusted_is, :adjusted, [ Unidom::Order::Order, Unidom::Order::OrderItem ]
78
+
77
79
  end
78
80
 
79
81
  end
@@ -35,52 +35,10 @@ describe Unidom::Order::Order, type: :model do
35
35
  { number: '9'*(number_length+1) } => 1,
36
36
  { number: 'A'*(number_length+1) } => 1
37
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
-
82
- #it_behaves_like 'validates numericality', model_attributes, :purchase_amount
83
- #it_behaves_like 'validates numericality', model_attributes, :aggregate_amount
38
+ it_behaves_like 'validates numericality', model_attributes, :purchase_amount,
39
+ range: 0..1_000_000_000, minimum_inclusive: true, maximum_inclusive: true
40
+ it_behaves_like 'validates numericality', model_attributes, :aggregate_amount,
41
+ range: 0..1_000_000_000, minimum_inclusive: true, maximum_inclusive: true
84
42
 
85
43
  order_item_1_attributes = {
86
44
  ordered_id: SecureRandom.uuid,
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Order
3
- VERSION = '1.5.3'.freeze
3
+ VERSION = '1.5.4'.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.3
4
+ version: 1.5.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-10 00:00:00.000000000 Z
11
+ date: 2017-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common