unidom-shopping 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2d10a943cfa1d8866729d933e502d44923a4b24
|
4
|
+
data.tar.gz: 48ac384eee11e6eb1514638122acf1bcbc089df7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7612c368bab2ac58f8cdeac6d299c8c6477e6dec539273a0849b54055817b452fc140c255a22e1a4ee3e907f1eb639a3f12b52df3fb131da45cec1a8af7ca815
|
7
|
+
data.tar.gz: 057cbb45b67aa01ce1e082bc7fc07e769bda3b84c550d8d480b73efb8437166f0a4f9d47d49aee70e8a7046349b2cd43313265ccf7cb9c8b52aa1f878a78d19d
|
@@ -7,15 +7,15 @@ 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: {
|
11
|
-
validates :quantity, presence: true, numericality: {
|
10
|
+
validates :unit_price, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
|
11
|
+
validates :quantity, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
|
12
12
|
|
13
13
|
belongs_to :shopping_cart, class_name: 'Unidom::Shopping::ShoppingCart'
|
14
14
|
belongs_to :shopper, polymorphic: true
|
15
15
|
belongs_to :shopped, polymorphic: true
|
16
16
|
|
17
|
-
scope :shopping_cart_is, ->(shopping_cart) { where shopping_cart_id: (shopping_cart
|
18
|
-
scope :shopped_by, ->(shopper) { where shopper:
|
19
|
-
scope :shopped_is, ->(shopped) { where shopped:
|
17
|
+
scope :shopping_cart_is, ->(shopping_cart) { where shopping_cart_id: to_id(shopping_cart) }
|
18
|
+
scope :shopped_by, ->(shopper) { where shopper: shopper }
|
19
|
+
scope :shopped_is, ->(shopped) { where shopped: shopped }
|
20
20
|
|
21
21
|
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Shopping::ShoppingItem'
|
@@ -20,49 +20,10 @@ 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
|
-
|
25
|
-
|
26
|
-
|
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
|
23
|
+
it_behaves_like 'validates numericality', model_attributes, :unit_price,
|
24
|
+
range: 0..1_000_000_000, minimum_inclusive: true, maximum_inclusive: true
|
25
|
+
it_behaves_like 'validates numericality', model_attributes, :quantity,
|
26
|
+
range: 0..1_000_000_000, minimum_inclusive: true, maximum_inclusive: true
|
66
27
|
|
67
28
|
shopping_cart_attributes = {
|
68
29
|
shopper_id: SecureRandom.uuid,
|
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: 1.7.
|
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-
|
11
|
+
date: 2017-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|