unidom-shopping 1.7.5 → 1.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -5
- data/app/models/unidom/shopping/shopping_item.rb +3 -3
- data/lib/rspec/models/unidom/shopping/concerns/as_shopped_shared_examples.rb +25 -0
- data/lib/rspec/models/unidom/shopping/shopping_item_spec.rb +2 -2
- data/lib/unidom/shopping/rspec_shared_examples.rb +1 -0
- data/lib/unidom/shopping/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 922ae84a2f71b54a02ffe525a24b976b6abe6e1c
|
4
|
+
data.tar.gz: f4aa840cde43050c52c0d8072b79f23263e33a8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a730aa34bf4b02b14798410e070c47ca8f5818c4265337eea3c1dbb3f40d213043edf89212324083e9a84b3c65030541c9c76653e8c6923389b9131b99f49fad
|
7
|
+
data.tar.gz: 408a75ebb7af70c4a20551556048114cb200ec3d34bea8a93e74fe6a7aa8c8d04a9c8812a9c803a5ffe1d73e6c6b30f99b8c19838cae90379e0aedaff2aedee3
|
data/README.md
CHANGED
@@ -138,6 +138,10 @@ def initialize_unidom
|
|
138
138
|
include Unidom::Shopping::Concerns::AsShop
|
139
139
|
end
|
140
140
|
|
141
|
+
Unidom::Product::Product.class_eval do
|
142
|
+
include Unidom::Shopping::Concerns::AsShopped
|
143
|
+
end
|
144
|
+
|
141
145
|
end
|
142
146
|
|
143
147
|
# spec/rails_helper.rb
|
@@ -148,13 +152,35 @@ initialize_unidom
|
|
148
152
|
require 'unidom/shopping/rspec_shared_examples'
|
149
153
|
|
150
154
|
# spec/models/unidom/party/shop_spec.rb
|
151
|
-
describe Unidom::Party::Shop do
|
155
|
+
describe Unidom::Party::Shop, type: :model do
|
152
156
|
|
153
|
-
|
154
|
-
|
155
|
-
|
157
|
+
context do
|
158
|
+
|
159
|
+
model_attribtues = {
|
160
|
+
name: 'WalMart'
|
161
|
+
}
|
162
|
+
|
163
|
+
it_behaves_like 'Unidom::Shopping::Concerns::AsShop', model_attribtues
|
164
|
+
|
165
|
+
end
|
156
166
|
|
157
|
-
|
167
|
+
end
|
168
|
+
|
169
|
+
# spec/models/unidom/product/product_spec.rb
|
170
|
+
describe Unidom::Product::Product, type: :model do
|
171
|
+
|
172
|
+
context do
|
173
|
+
|
174
|
+
model_attribtues = {
|
175
|
+
name: 'Model X',
|
176
|
+
abbreviation: 'MX',
|
177
|
+
measurement_unit: 'set',
|
178
|
+
packing_norm: '1 per 1'
|
179
|
+
}
|
180
|
+
|
181
|
+
it_behaves_like 'Unidom::Shopping::Concerns::AsShopped', model_attribtues
|
182
|
+
|
183
|
+
end
|
158
184
|
|
159
185
|
end
|
160
186
|
```
|
@@ -14,8 +14,8 @@ class Unidom::Shopping::ShoppingItem < Unidom::Shopping::ApplicationRecord
|
|
14
14
|
belongs_to :shopper, polymorphic: true
|
15
15
|
belongs_to :shopped, polymorphic: true
|
16
16
|
|
17
|
-
scope :shopping_cart_is, ->(shopping_cart) { where
|
18
|
-
scope :shopped_by, ->(shopper) { where shopper:
|
19
|
-
scope :shopped_is, ->(shopped) { where shopped:
|
17
|
+
scope :shopping_cart_is, ->(shopping_cart) { where shopping_cart: 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'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
shared_examples 'Unidom::Shopping::Concerns::AsShopped' do |model_attributes|
|
2
|
+
|
3
|
+
context do
|
4
|
+
|
5
|
+
shopping_item_1_attributes = {
|
6
|
+
shopping_cart_id: SecureRandom.uuid,
|
7
|
+
shopper_id: SecureRandom.uuid,
|
8
|
+
shopper_type: 'Unidom::Shopping::Shopper::Mock',
|
9
|
+
unit_price: 12.00,
|
10
|
+
quantity: 5.00
|
11
|
+
}
|
12
|
+
|
13
|
+
shopping_item_2_attributes = {
|
14
|
+
shopping_cart_id: SecureRandom.uuid,
|
15
|
+
shopper_id: SecureRandom.uuid,
|
16
|
+
shopper_type: 'Unidom::Shopping::Shopper::Mock',
|
17
|
+
unit_price: 10.00,
|
18
|
+
quantity: 6.00
|
19
|
+
}
|
20
|
+
|
21
|
+
it_behaves_like 'has_many', model_attributes, :shopping_items, Unidom::Shopping::ShoppingItem, [ shopping_item_1_attributes, shopping_item_2_attributes ]
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -11,9 +11,9 @@ describe Unidom::Shopping::ShoppingItem, type: :model do
|
|
11
11
|
model_attributes = {
|
12
12
|
shopping_cart_id: SecureRandom.uuid,
|
13
13
|
shopper_id: SecureRandom.uuid,
|
14
|
-
shopper_type: 'Unidom::Shopping::Shopper',
|
14
|
+
shopper_type: 'Unidom::Shopping::Shopper::Mock',
|
15
15
|
shopped_id: SecureRandom.uuid,
|
16
|
-
shopped_type: 'Unidom::Shopping::Shopped',
|
16
|
+
shopped_type: 'Unidom::Shopping::Shopped::Mock',
|
17
17
|
unit_price: 12.00,
|
18
18
|
quantity: 5.00
|
19
19
|
}
|
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.6
|
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-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- db/migrate/20020501000000_create_unidom_shopping_carts.rb
|
56
56
|
- db/migrate/20020502000000_create_unidom_shopping_items.rb
|
57
57
|
- lib/rspec/models/unidom/shopping/concerns/as_shop_shared_examples.rb
|
58
|
+
- lib/rspec/models/unidom/shopping/concerns/as_shopped_shared_examples.rb
|
58
59
|
- lib/rspec/models/unidom/shopping/shopping_cart_spec.rb
|
59
60
|
- lib/rspec/models/unidom/shopping/shopping_item_spec.rb
|
60
61
|
- lib/tasks/shopping_tasks.rake
|