unidom-order 1.5.7 → 2.0.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
- SHA1:
3
- metadata.gz: 12cacfafcbbcc51b5238c24605c0b5948663d03a
4
- data.tar.gz: f6011e5192b4daa6a704aef036efb415684f9450
2
+ SHA256:
3
+ metadata.gz: 65be3c651c2b77bfef5f74d06723a94f8b36c060a3418be80c8c92322ebe4c4c
4
+ data.tar.gz: 662944e10031a663cda34bec754b4ad465021f286b5ab9efd3a126dd81e2ab7a
5
5
  SHA512:
6
- metadata.gz: 284e81d39db701cf08269d0440a1d0b66716b9d4e879a188a6c65a93c580b998d10b8c5d53b87e52424cb7792a3502c8d57522badd855d9ceeba5c69e9418576
7
- data.tar.gz: d38febdb15f38164ed736004ff699d68bea77684a891d79b7b6ab472b2c9b52bb6926cd63081d2c6560d63332eb69960959d3b61ecf77cc3dcf59a3915bb2fa8
6
+ metadata.gz: f6b87ba705f596f32aa92e97e5e228fbecebc64da2bbae6b9de470abcb11e71ac3d0ff132e4c00d3411697b2907e8ea2bf0677ddd67e16d7fe818a5e3058ce9c
7
+ data.tar.gz: f2e5a93ece0a2de244afbe19783ec093c4cfe99e7b55a3c5cc781a3737243553e1600f4f12f8894d0b0dce4d123038b181a310de118159a175ac9c084e38d06d
data/README.md CHANGED
@@ -192,6 +192,12 @@ Unidom::Party::Person.class_eval do
192
192
 
193
193
  end
194
194
 
195
+ Unidom::Party::Shop.class_eval do
196
+
197
+ include Unidom::Order::Concerns::AsOrderTaker
198
+
199
+ end
200
+
195
201
  # spec/support/unidom_rspec_shared_examples.rb
196
202
  require 'unidom/order/rspec_shared_examples'
197
203
 
@@ -200,5 +206,12 @@ describe Unidom::Party::Person, type: :model do
200
206
 
201
207
  it_behaves_like 'Unidom::Order::Concerns::AsOrderPlacer', model_attributes
202
208
 
209
+ end
210
+
211
+ # spec/models/unidom/party/shop_spec.rb
212
+ describe Unidom::Party::Shop, type: :model do
213
+
214
+ it_behaves_like 'Unidom::Order::Concerns::AsOrderTaker', model_attributes
215
+
203
216
  end
204
217
  ```
@@ -1,6 +1,12 @@
1
1
  ##
2
2
  # Application controller 是模块内所有控制器的基类。
3
3
 
4
- class Unidom::Order::ApplicationController < ActionController::Base
5
- protect_from_forgery with: :exception
4
+ module Unidom
5
+ module Order
6
+
7
+ class ApplicationController < ActionController::Base
8
+ protect_from_forgery with: :exception
9
+ end
10
+
11
+ end
6
12
  end
@@ -1,2 +1,8 @@
1
- module Unidom::Order::ApplicationHelper
1
+ module Unidom
2
+ module Order
3
+
4
+ module ApplicationHelper
5
+ end
6
+
7
+ end
2
8
  end
@@ -1,5 +1,11 @@
1
1
  ##
2
2
  # Application job 是模块内所有异步任务的基类。
3
3
 
4
- class Unidom::Order::ApplicationJob < ActiveJob::Base
4
+ module Unidom
5
+ module Order
6
+
7
+ class ApplicationJob < ActiveJob::Base
8
+ end
9
+
10
+ end
5
11
  end
@@ -1,7 +1,13 @@
1
1
  ##
2
2
  # Application mailer 是模块内所有电子邮件发送类的基类。
3
3
 
4
- class Unidom::Order::ApplicationMailer < ActionMailer::Base
5
- default from: 'from@example.com'
6
- layout 'mailer'
4
+ module Unidom
5
+ module Order
6
+
7
+ class ApplicationMailer < ActionMailer::Base
8
+ default from: 'from@example.com'
9
+ layout 'mailer'
10
+ end
11
+
12
+ end
7
13
  end
@@ -1,6 +1,12 @@
1
1
  ##
2
2
  # Application record 是模块内所有模型的抽象基类。
3
3
 
4
- class Unidom::Order::ApplicationRecord < ActiveRecord::Base
5
- self.abstract_class = true
4
+ module Unidom
5
+ module Order
6
+
7
+ class ApplicationRecord < ActiveRecord::Base
8
+ self.abstract_class = true
9
+ end
10
+
11
+ end
6
12
  end
@@ -1,34 +1,42 @@
1
- module Unidom::Order::Concerns::AsAdjusted
1
+ module Unidom
2
+ module Order
3
+ module Concerns
4
+
5
+ module AsAdjusted
6
+
7
+ extend ActiveSupport::Concern
8
+
9
+ included do |includer|
10
+
11
+ has_many :adjustments, class_name: 'Unidom::Order::OrderAdjustment', as: :adjusted
12
+
13
+ def is_adjusted!(amount, due_to: 'FRGT', at: Time.now)
14
+ query = adjustments.adjustment_factor_coded_as(due_to).valid_at(now: at).alive
15
+ adjustment = query.first
16
+ if adjustment.present?
17
+ if 0==amount
18
+ adjustment.soft_destroy
19
+ else
20
+ adjustment.amount = amount
21
+ adjustment.save!
22
+ end
23
+ else
24
+ adjustment = query.create! amount: amount, opened_at: at
25
+ end
26
+ adjustment
27
+ end
28
+
29
+ def is_adjusted?(due_to: 'FRGT', at: Time.now)
30
+ adjustments.adjustment_factor_coded_as(due_to).valid_at(now: at).alive.exists?
31
+ end
2
32
 
3
- extend ActiveSupport::Concern
4
-
5
- included do |includer|
6
-
7
- has_many :adjustments, class_name: 'Unidom::Order::OrderAdjustment', as: :adjusted
33
+ end
8
34
 
9
- def is_adjusted!(amount, due_to: 'FRGT', at: Time.now)
10
- query = adjustments.adjustment_factor_coded_as(due_to).valid_at(now: at).alive
11
- adjustment = query.first
12
- if adjustment.present?
13
- if 0==amount
14
- adjustment.soft_destroy
15
- else
16
- adjustment.amount = amount
17
- adjustment.save!
35
+ module ClassMethods
18
36
  end
19
- else
20
- adjustment = query.create! amount: amount, opened_at: at
37
+
21
38
  end
22
- adjustment
23
- end
24
39
 
25
- def is_adjusted?(due_to: 'FRGT', at: Time.now)
26
- adjustments.adjustment_factor_coded_as(due_to).valid_at(now: at).alive.exists?
27
40
  end
28
-
29
- end
30
-
31
- module ClassMethods
32
41
  end
33
-
34
42
  end
@@ -1,14 +1,22 @@
1
- module Unidom::Order::Concerns::AsOrderPlacer
1
+ module Unidom
2
+ module Order
3
+ module Concerns
2
4
 
3
- extend ActiveSupport::Concern
5
+ module AsOrderPlacer
4
6
 
5
- included do |includer|
7
+ extend ActiveSupport::Concern
6
8
 
7
- has_many :placed_orders, class_name: 'Unidom::Order::Order', as: :placer
9
+ included do |includer|
8
10
 
9
- end
11
+ has_many :placed_orders, class_name: 'Unidom::Order::Order', as: :placer
10
12
 
11
- module ClassMethods
12
- end
13
+ end
14
+
15
+ module ClassMethods
16
+ end
13
17
 
18
+ end
19
+
20
+ end
21
+ end
14
22
  end
@@ -1,14 +1,22 @@
1
- module Unidom::Order::Concerns::AsOrderTaker
1
+ module Unidom
2
+ module Order
3
+ module Concerns
2
4
 
3
- extend ActiveSupport::Concern
5
+ module AsOrderTaker
4
6
 
5
- included do |includer|
7
+ extend ActiveSupport::Concern
6
8
 
7
- has_many :taken_orders, class_name: 'Unidom::Order::Order', as: :taker
9
+ included do |includer|
8
10
 
9
- end
11
+ has_many :taken_orders, class_name: 'Unidom::Order::Order', as: :taker
10
12
 
11
- module ClassMethods
12
- end
13
+ end
14
+
15
+ module ClassMethods
16
+ end
13
17
 
18
+ end
19
+
20
+ end
21
+ end
14
22
  end
@@ -1,23 +1,29 @@
1
1
  ##
2
2
  # Order 是订单。
3
3
 
4
- class Unidom::Order::Order < Unidom::Order::ApplicationRecord
4
+ module Unidom
5
+ module Order
5
6
 
6
- self.table_name = 'unidom_orders'
7
+ class Order < ApplicationRecord
7
8
 
8
- include Unidom::Common::Concerns::ModelExtension
9
- include Unidom::Order::Concerns::AsAdjusted
9
+ self.table_name = 'unidom_orders'
10
10
 
11
- validates :number, presence: true, length: { is: self.columns_hash['number'].limit }
12
- validates :purchase_amount, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
13
- validates :aggregate_amount, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
11
+ include Unidom::Common::Concerns::ModelExtension
12
+ include Unidom::Order::Concerns::AsAdjusted
14
13
 
15
- belongs_to :placer, polymorphic: true
16
- belongs_to :taker, polymorphic: true
14
+ validates :number, presence: true, length: { is: self.columns_hash['number'].limit }
15
+ validates :purchase_amount, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
16
+ validates :aggregate_amount, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
17
17
 
18
- has_many :items, class_name: 'Unidom::Order::OrderItem'
18
+ belongs_to :placer, polymorphic: true
19
+ belongs_to :taker, polymorphic: true
19
20
 
20
- scope :placed_by, ->(placer) { where placer: placer }
21
- scope :taken_by, ->(taker) { where taker: taker }
21
+ has_many :items, class_name: 'Unidom::Order::OrderItem'
22
22
 
23
- end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Order::Order'
23
+ scope :placed_by, ->(placer) { where placer: placer }
24
+ scope :taken_by, ->(taker) { where taker: taker }
25
+
26
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Order::Order'
27
+
28
+ end
29
+ end
@@ -1,44 +1,50 @@
1
1
  ##
2
2
  # Order Adjustment 是订单调整项。
3
3
 
4
- class Unidom::Order::OrderAdjustment < Unidom::Order::ApplicationRecord
4
+ module Unidom
5
+ module Order
5
6
 
6
- self.table_name = 'unidom_order_adjustments'
7
+ class OrderAdjustment < ApplicationRecord
7
8
 
8
- include Unidom::Common::Concerns::ModelExtension
9
- include ProgneTapera::EnumCode
9
+ self.table_name = 'unidom_order_adjustments'
10
10
 
11
- validates :amount, presence: true, numericality: { greater_than_or_equal_to: -1_000_000_000, less_than_or_equal_to: 1_000_000_000 }
11
+ include Unidom::Common::Concerns::ModelExtension
12
+ include ProgneTapera::EnumCode
12
13
 
13
- belongs_to :adjusted, polymorphic: true
14
+ validates :amount, presence: true, numericality: { greater_than_or_equal_to: -1_000_000_000, less_than_or_equal_to: 1_000_000_000 }
14
15
 
15
- scope :adjusted_is, ->(adjusted) { where adjusted: adjusted }
16
+ belongs_to :adjusted, polymorphic: true
16
17
 
17
- code :adjustment_factor, Unidom::Order::AdjustmentFactor
18
+ scope :adjusted_is, ->(adjusted) { where adjusted: adjusted }
18
19
 
19
- ##
20
- # 对订单或者订单项 adjusted 进行调整。调整金额为 amount ,缺省为 0 。调整原因是 due_to ,缺省是 FRGT 。调整时间是 opened_at ,缺省为当前时间。如:
21
- # Unidom::Order::OrderAdjustment.adjust! order, amount: 7.90, due_to: 'LTAX'
22
- def self.adjust!(adjusted, amount: 0, due_to: 'FRGT', opened_at: Time.now)
20
+ code :adjustment_factor, Unidom::Order::AdjustmentFactor
23
21
 
24
- assert_present! :adjusted, adjusted
25
- assert_present! :amount, amount
26
- assert_present! :due_to, due_to
27
- assert_present! :opened_at, opened_at
22
+ ##
23
+ # 对订单或者订单项 adjusted 进行调整。调整金额为 amount ,缺省为 0 。调整原因是 due_to ,缺省是 FRGT 。调整时间是 opened_at ,缺省为当前时间。如:
24
+ # Unidom::Order::OrderAdjustment.adjust! order, amount: 7.90, due_to: 'LTAX'
25
+ def self.adjust!(adjusted, amount: 0, due_to: 'FRGT', opened_at: Time.now)
28
26
 
29
- query = adjusted_is(adjusted).adjustment_factor_coded_as(due_to).valid_at(now: opened_at).alive
30
- adjustment = query.first
31
- if adjustment.present?
32
- if 0==amount
33
- adjustment.soft_destroy
34
- else
35
- adjustment.amount = amount
36
- adjustment.save!
27
+ assert_present! :adjusted, adjusted
28
+ assert_present! :amount, amount
29
+ assert_present! :due_to, due_to
30
+ assert_present! :opened_at, opened_at
31
+
32
+ query = adjusted_is(adjusted).adjustment_factor_coded_as(due_to).valid_at(now: opened_at).alive
33
+ adjustment = query.first
34
+ if adjustment.present?
35
+ if 0==amount
36
+ adjustment.soft_destroy
37
+ else
38
+ adjustment.amount = amount
39
+ adjustment.save!
40
+ end
41
+ else
42
+ adjustment = query.create! amount: amount, opened_at: opened_at
43
+ end
44
+ adjustment
37
45
  end
38
- else
39
- adjustment = query.create! amount: amount, opened_at: opened_at
40
- end
41
- adjustment
42
- end
43
46
 
44
- end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Order::OrderAdjustment'
47
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Order::OrderAdjustment'
48
+
49
+ end
50
+ end
@@ -1,42 +1,48 @@
1
1
  ##
2
2
  # Order Item 是订单项。
3
3
 
4
- class Unidom::Order::OrderItem < Unidom::Order::ApplicationRecord
5
-
6
- self.table_name = 'unidom_order_items'
7
-
8
- include Unidom::Common::Concerns::ModelExtension
9
- include Unidom::Order::Concerns::AsAdjusted
10
-
11
- #validates :ordinal, presence: true, numericality: { only_integer: true, greater_than: 0, less_than: 1_000_000_000 }
12
- validates :unit_price, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
13
- validates :quantity, presence: true, numericality: { greater_than: 0, less_than_or_equal_to: 1_000_000_000 }
14
- validates :purchase_amount, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
15
- validates :subtotal_amount, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
16
-
17
- belongs_to :order, class_name: 'Unidom::Order::Order'
18
- belongs_to :ordered, polymorphic: true
19
- belongs_to :placer, polymorphic: true
20
-
21
- scope :order_is, ->(order) { where order: order }
22
- scope :ordered_is, ->(ordered) { where ordered: ordered }
23
- scope :placed_by, ->(placer) { where placer: placer }
24
-
25
- ##
26
- # 订购商品 ordered ,放入订单 of 。订购者为 by ,缺省为订单的下单者。单价为 unit_price ,缺省值为 0 。数量为 quantity ,缺省值为 1。如:
27
- # Unidom::Order::OrderItem.order! coca_cola, of: order, by: current_person, unit_price: 3.50, quantity: 2
28
- def self.order!(ordered, of: nil, by: of.placer, unit_price: 0, quantity: 1)
29
- item = of.items.ordered_is(ordered).placed_by(by).valid_at.alive.first
30
- if item.present?
31
- item.quantity += quantity
32
- item.unit_price = unit_price
33
- item.purchase_amount = item.unit_price*item.quantity
34
- item.subtotal_amount = item.purchase_amount+item.adjustments.valid_at.alive.sum(:amount).to_f
35
- item.save!
36
- else
37
- ordinal = 1+of.items.valid_at.alive.maximum(:ordinal).to_i
38
- of.items.create! ordered: ordered, placer: by, ordinal: ordinal, quantity: quantity, unit_price: unit_price, purchase_amount: unit_price*quantity, subtotal_amount: unit_price*quantity, opened_at: Time.now
39
- end
40
- end
4
+ module Unidom
5
+ module Order
6
+
7
+ class OrderItem < ApplicationRecord
8
+
9
+ self.table_name = 'unidom_order_items'
10
+
11
+ include Unidom::Common::Concerns::ModelExtension
12
+ include Unidom::Order::Concerns::AsAdjusted
13
+
14
+ #validates :ordinal, presence: true, numericality: { only_integer: true, greater_than: 0, less_than: 1_000_000_000 }
15
+ validates :unit_price, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
16
+ validates :quantity, presence: true, numericality: { greater_than: 0, less_than_or_equal_to: 1_000_000_000 }
17
+ validates :purchase_amount, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
18
+ validates :subtotal_amount, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
19
+
20
+ belongs_to :order, class_name: 'Unidom::Order::Order'
21
+ belongs_to :ordered, polymorphic: true
22
+ belongs_to :placer, polymorphic: true
23
+
24
+ scope :order_is, ->(order) { where order: order }
25
+ scope :ordered_is, ->(ordered) { where ordered: ordered }
26
+ scope :placed_by, ->(placer) { where placer: placer }
27
+
28
+ ##
29
+ # 订购商品 ordered ,放入订单 of 。订购者为 by ,缺省为订单的下单者。单价为 unit_price ,缺省值为 0 。数量为 quantity ,缺省值为 1。如:
30
+ # Unidom::Order::OrderItem.order! coca_cola, of: order, by: current_person, unit_price: 3.50, quantity: 2
31
+ def self.order!(ordered, of: nil, by: of.placer, unit_price: 0, quantity: 1)
32
+ item = of.items.ordered_is(ordered).placed_by(by).valid_at.alive.first
33
+ if item.present?
34
+ item.quantity += quantity
35
+ item.unit_price = unit_price
36
+ item.purchase_amount = item.unit_price*item.quantity
37
+ item.subtotal_amount = item.purchase_amount+item.adjustments.valid_at.alive.sum(:amount).to_f
38
+ item.save!
39
+ else
40
+ ordinal = 1+of.items.valid_at.alive.maximum(:ordinal).to_i
41
+ of.items.create! ordered: ordered, placer: by, ordinal: ordinal, quantity: quantity, unit_price: unit_price, purchase_amount: unit_price*quantity, subtotal_amount: unit_price*quantity, opened_at: Time.now
42
+ end
43
+ end
44
+
45
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Order::OrderItem'
41
46
 
42
- end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Order::OrderItem'
47
+ end
48
+ end
@@ -1,9 +1,15 @@
1
1
  # Adjustment Factor 是调整因素。
2
2
 
3
- class Unidom::Order::AdjustmentFactor < ActiveRecord::Type::Value
3
+ module Unidom
4
+ module Order
4
5
 
5
- include ProgneTapera::EnumConfig
6
+ class AdjustmentFactor < ActiveRecord::Type::Value
6
7
 
7
- enum :unidom_adjustment_factor
8
+ include ProgneTapera::EnumConfig
8
9
 
10
+ enum :unidom_adjustment_factor
11
+
12
+ end
13
+
14
+ end
9
15
  end
@@ -2,7 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>Unidom Order</title>
5
- <%= stylesheet_link_tag "unidom/order/application", media: "all" %>
5
+ <%= stylesheet_link_tag 'unidom/order/application', media: 'all' %>
6
6
  <%= csrf_meta_tags %>
7
7
  </head>
8
8
  <body>
@@ -1,4 +1,4 @@
1
- class CreateUnidomOrders < ActiveRecord::Migration
1
+ class CreateUnidomOrders < ActiveRecord::Migration[6.0]
2
2
 
3
3
  def change
4
4
 
@@ -18,9 +18,9 @@ class CreateUnidomOrders < ActiveRecord::Migration
18
18
  t.text :description
19
19
 
20
20
  t.string :slug, null: false, default: nil, limit: 200
21
- t.column :state, 'char(1)', null: false, default: 'C'
22
- t.datetime :opened_at, null: false, default: ::Time.utc(1970)
23
- t.datetime :closed_at, null: false, default: ::Time.utc(3000)
21
+ t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
22
+ t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
23
+ t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
24
24
  t.boolean :defunct, null: false, default: false
25
25
  t.jsonb :notation, null: false, default: {}
26
26
 
@@ -1,6 +1,6 @@
1
1
  # Order Item 是订单项。
2
2
 
3
- class CreateUnidomOrderItems < ActiveRecord::Migration
3
+ class CreateUnidomOrderItems < ActiveRecord::Migration[6.0]
4
4
 
5
5
  def change
6
6
 
@@ -22,9 +22,9 @@ class CreateUnidomOrderItems < ActiveRecord::Migration
22
22
  t.text :instruction
23
23
  t.text :description
24
24
 
25
- t.column :state, 'char(1)', null: false, default: 'C'
26
- t.datetime :opened_at, null: false, default: ::Time.utc(1970)
27
- t.datetime :closed_at, null: false, default: ::Time.utc(3000)
25
+ t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
26
+ t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
27
+ t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
28
28
  t.boolean :defunct, null: false, default: false
29
29
  t.jsonb :notation, null: false, default: {}
30
30
 
@@ -32,7 +32,7 @@ class CreateUnidomOrderItems < ActiveRecord::Migration
32
32
 
33
33
  end
34
34
 
35
- add_index :unidom_order_items, :order_id
35
+ #add_index :unidom_order_items, :order_id
36
36
  add_index :unidom_order_items, :ordered_id
37
37
  add_index :unidom_order_items, :placer_id
38
38
 
@@ -1,4 +1,4 @@
1
- class CreateUnidomOrderAdjustments < ActiveRecord::Migration
1
+ class CreateUnidomOrderAdjustments < ActiveRecord::Migration[6.0]
2
2
 
3
3
  def change
4
4
 
@@ -15,9 +15,9 @@ class CreateUnidomOrderAdjustments < ActiveRecord::Migration
15
15
  t.text :instruction
16
16
  t.text :description
17
17
 
18
- t.column :state, 'char(1)', null: false, default: 'C'
19
- t.datetime :opened_at, null: false, default: ::Time.utc(1970)
20
- t.datetime :closed_at, null: false, default: ::Time.utc(3000)
18
+ t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
19
+ t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
20
+ t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
21
21
  t.boolean :defunct, null: false, default: false
22
22
  t.jsonb :notation, null: false, default: {}
23
23
 
@@ -0,0 +1,25 @@
1
+ shared_examples 'Unidom::Order::Concerns::AsOrderTaker' do |model_attributes|
2
+
3
+ context do
4
+
5
+ order_1_attributes = {
6
+ placer_id: SecureRandom.uuid,
7
+ placer_type: 'Unidom::Order::Placer::Mock',
8
+ number: SecureRandom.hex(6),
9
+ purchase_amount: 10.00,
10
+ aggregate_amount: 10.00
11
+ }
12
+
13
+ order_1_attributes = {
14
+ placer_id: SecureRandom.uuid,
15
+ placer_type: 'Unidom::Order::Placer::Mock',
16
+ number: SecureRandom.hex(6),
17
+ purchase_amount: 20.00,
18
+ aggregate_amount: 20.00
19
+ }
20
+
21
+ it_behaves_like 'has_many', model_attributes, :taken_orders, Unidom::Order::Order, [ order_1_attributes, order_1_attributes ]
22
+
23
+ end
24
+
25
+ end
@@ -1 +1,2 @@
1
1
  require 'rspec/models/unidom/order/concerns/as_order_placer_shared_examples'
2
+ require 'rspec/models/unidom/order/concerns/as_order_taker_shared_examples'
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Order
3
- VERSION = '1.5.7'.freeze
3
+ VERSION = '2.0.1'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-order
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.7
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-11 00:00:00.000000000 Z
11
+ date: 2021-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.9'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.9'
26
+ version: '2.0'
27
27
  description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
28
28
  The Order domain model engine includes Order, Order Item, and Order Adjustment models.
29
29
  Unidom (统一领域对象模型)是一系列的领域模型引擎。订单领域模型引擎包括订单、订单项和订单调整的模型。
@@ -59,6 +59,7 @@ files:
59
59
  - db/migrate/20020602000000_create_unidom_order_items.rb
60
60
  - db/migrate/20020603000000_create_unidom_order_adjustments.rb
61
61
  - lib/rspec/models/unidom/order/concerns/as_order_placer_shared_examples.rb
62
+ - lib/rspec/models/unidom/order/concerns/as_order_taker_shared_examples.rb
62
63
  - lib/rspec/models/unidom/order/order_adjustment_spec.rb
63
64
  - lib/rspec/models/unidom/order/order_item_spec.rb
64
65
  - lib/rspec/models/unidom/order/order_spec.rb
@@ -71,11 +72,11 @@ files:
71
72
  - lib/unidom/order/types_rspec.rb
72
73
  - lib/unidom/order/validators_rspec.rb
73
74
  - lib/unidom/order/version.rb
74
- homepage: https://github.com/topbitdu/unidom-order
75
+ homepage: https://gitee.com/Unidom/unidom-order
75
76
  licenses:
76
77
  - MIT
77
78
  metadata: {}
78
- post_install_message:
79
+ post_install_message:
79
80
  rdoc_options: []
80
81
  require_paths:
81
82
  - lib
@@ -90,9 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
91
  - !ruby/object:Gem::Version
91
92
  version: '0'
92
93
  requirements: []
93
- rubyforge_project:
94
- rubygems_version: 2.6.4
95
- signing_key:
94
+ rubygems_version: 3.2.3
95
+ signing_key:
96
96
  specification_version: 4
97
97
  summary: Unidom Order Domain Model Engine 订单领域模型引擎
98
98
  test_files: []