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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18b8f79a6b53a4c46f71f1853edcf0f71f0eafc3
4
- data.tar.gz: 9ab723541b47c75228ba140165d6357bb20c6a43
3
+ metadata.gz: 922ae84a2f71b54a02ffe525a24b976b6abe6e1c
4
+ data.tar.gz: f4aa840cde43050c52c0d8072b79f23263e33a8f
5
5
  SHA512:
6
- metadata.gz: d7bfa44364fb61b8745398e9df8c8f874df95a278ec5bc9cadf003b7cf58226c44df76ef438c6b008c11effb69a521ad651ae540778fecc3412f6ffe4f5dcff2
7
- data.tar.gz: cf160c2906ca0a49ecca2cd8289b98ba72c7ea31874327ec62cf92b991fa35b13dbc93690c765d5bb16fb52c5e14dcd6a1ade78694d0f41fcb181e3cea2197aa
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
- model_attribtues = {
154
- name: 'WalMart'
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
- it_behaves_like 'Unidom::Shopping::Concerns::AsShop', model_attribtues
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 shopping_cart_id: to_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: 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
  }
@@ -1 +1,2 @@
1
1
  require 'rspec/models/unidom/shopping/concerns/as_shop_shared_examples'
2
+ require 'rspec/models/unidom/shopping/concerns/as_shopped_shared_examples'
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Shopping
3
- VERSION = '1.7.5'.freeze
3
+ VERSION = '1.7.6'.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.5
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-03-23 00:00:00.000000000 Z
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