unidom-shopping 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: a5eb67e0ec808b5df88cb9c5afd84343c7c6d216
|
4
|
+
data.tar.gz: 497b7de5e12cbf9efd9ad29beb4ef768af16a2d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd2eac167ab34a0e25396cae5ea6f431f331d5fc9e5e6ccac14624bc61fba0c9b86e8503d8364a0779dff91d714d93168615634070d60fe780128854fc57852e
|
7
|
+
data.tar.gz: addbf52fc9601771b06b1fc35c958c98c55eb6c347d40e01344adfdf45757415be84a166130d5d17756727fb112fc413b27dd790c2d67fba86418741d7f4201f
|
@@ -7,8 +7,8 @@ class Unidom::Shopping::ShoppingItem < Unidom::Shopping::ApplicationRecord
|
|
7
7
|
|
8
8
|
include Unidom::Common::Concerns::ModelExtension
|
9
9
|
|
10
|
-
validates :unit_price, presence: true, numericality: { greater_than: 0, less_than:
|
11
|
-
validates :quantity, presence: true, numericality: { greater_than: 0, less_than:
|
10
|
+
validates :unit_price, presence: true, numericality: { greater_than: 0, less_than: 1_000_000_000 }
|
11
|
+
validates :quantity, presence: true, numericality: { greater_than: 0, less_than: 1_000_000_000 }
|
12
12
|
|
13
13
|
belongs_to :shopping_cart, class_name: 'Unidom::Shopping::ShoppingCart'
|
14
14
|
belongs_to :shopper, polymorphic: true
|
@@ -20,6 +20,50 @@ describe Unidom::Shopping::ShoppingItem, type: :model do
|
|
20
20
|
|
21
21
|
it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
|
22
22
|
|
23
|
+
it_behaves_like 'validates', model_attributes, :unit_price,
|
24
|
+
{ } => 0,
|
25
|
+
{ unit_price: nil } => 2,
|
26
|
+
{ unit_price: '' } => 2,
|
27
|
+
{ unit_price: '1' } => 0,
|
28
|
+
{ unit_price: 1 } => 0,
|
29
|
+
{ unit_price: 'A' } => 1,
|
30
|
+
{ unit_price: '1.23' } => 0,
|
31
|
+
{ unit_price: 1.23 } => 0,
|
32
|
+
{ unit_price: '-0.01' } => 1,
|
33
|
+
{ unit_price: -0.01 } => 1,
|
34
|
+
{ unit_price: '0' } => 1,
|
35
|
+
{ unit_price: 0 } => 1,
|
36
|
+
{ unit_price: '0.01' } => 0,
|
37
|
+
{ unit_price: 0.01 } => 0,
|
38
|
+
{ unit_price: '999_999_999.99' } => 0,
|
39
|
+
{ unit_price: 999_999_999.99 } => 0,
|
40
|
+
{ unit_price: '1_000_000_000' } => 1,
|
41
|
+
{ unit_price: 1_000_000_000 } => 1,
|
42
|
+
{ unit_price: '1_000_000_000.01' } => 1,
|
43
|
+
{ unit_price: 1_000_000_000.01 } => 1
|
44
|
+
|
45
|
+
it_behaves_like 'validates', model_attributes, :quantity,
|
46
|
+
{ } => 0,
|
47
|
+
{ quantity: nil } => 2,
|
48
|
+
{ quantity: '' } => 2,
|
49
|
+
{ quantity: '1' } => 0,
|
50
|
+
{ quantity: 1 } => 0,
|
51
|
+
{ quantity: 'A' } => 1,
|
52
|
+
{ quantity: '1.23' } => 0,
|
53
|
+
{ quantity: 1.23 } => 0,
|
54
|
+
{ quantity: '-0.01' } => 1,
|
55
|
+
{ quantity: -0.01 } => 1,
|
56
|
+
{ quantity: '0' } => 1,
|
57
|
+
{ quantity: 0 } => 1,
|
58
|
+
{ quantity: '0.01' } => 0,
|
59
|
+
{ quantity: 0.01 } => 0,
|
60
|
+
{ quantity: '999_999_999.99' } => 0,
|
61
|
+
{ quantity: 999_999_999.99 } => 0,
|
62
|
+
{ quantity: '1_000_000_000' } => 1,
|
63
|
+
{ quantity: 1_000_000_000 } => 1,
|
64
|
+
{ quantity: '1_000_000_000.01' } => 1,
|
65
|
+
{ quantity: 1_000_000_000.01 } => 1
|
66
|
+
|
23
67
|
end
|
24
68
|
|
25
69
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-shopping
|
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-
|
11
|
+
date: 2017-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|