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: 5276d58133bb310c90d7012437cffe72bda62a52
4
- data.tar.gz: 50c27ce29d77fa06bb3bd955ac0d7aa77b6b0eec
3
+ metadata.gz: d2d10a943cfa1d8866729d933e502d44923a4b24
4
+ data.tar.gz: 48ac384eee11e6eb1514638122acf1bcbc089df7
5
5
  SHA512:
6
- metadata.gz: d726037483b38c8ada6a3135a1de53de5a2eb5161ee4f68222b64c7b4a04ed5f77f83a003461d2d28e0a85674c585739f598e85f738e33207274ef050e1fb65a
7
- data.tar.gz: 6e1ed21dcdca1f290c3d3bebfc042e817c2e601bc365a463d2a622a5118e715a54f1776777ab7ab50afddadda16afcd39724faffd69866d0edeea35ae123318e
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: { greater_than: 0, less_than: 1_000_000_000 }
11
- validates :quantity, presence: true, numericality: { greater_than: 0, less_than: 1_000_000_000 }
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.respond_to?(:id) ? shopping_cart.id : shopping_cart) }
18
- scope :shopped_by, ->(shopper) { where shopper: shopper }
19
- scope :shopped_is, ->(shopped) { where shopped: 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
- { } => 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
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,
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Shopping
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-shopping
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-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common