Sha256: 3a68834bf1c7d14fe3cf470771bd6de864c64079346aa8f41a25c8374e8b4dd6

Contents?: true

Size: 1.73 KB

Versions: 7

Compression:

Stored size: 1.73 KB

Contents

describe Unidom::Order::OrderItem, type: :model do

  before :each do
  end

  after :each do
  end

  context do

    model_attributes = {
      order_id:        SecureRandom.uuid,
      ordered_id:      SecureRandom.uuid,
      ordered_type:    'Unidom::Order::Ordered::Mock',
      placer_id:       SecureRandom.uuid,
      placer_type:     'Unidom::Order::Placer::Mock',
      ordinal:         1,
      unit_price:      10.00,
      quantity:        12.00,
      purchase_amount: 120.00,
      subtotal_amount: 100.00
    }

    it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes

    it_behaves_like 'validates numericality', model_attributes, :unit_price,
      range: 0..1_000_000_000, minimum_inclusive: true,  maximum_inclusive: true
    it_behaves_like 'validates numericality', model_attributes, :quantity,
      range: 0..1_000_000_000, minimum_inclusive: false, maximum_inclusive: true
    it_behaves_like 'validates numericality', model_attributes, :purchase_amount,
      range: 0..1_000_000_000, minimum_inclusive: true,  maximum_inclusive: true
    it_behaves_like 'validates numericality', model_attributes, :subtotal_amount,
      range: 0..1_000_000_000, minimum_inclusive: true,  maximum_inclusive: true

    order_attributes = {
      placer_id:        SecureRandom.uuid,
      placer_type:      'Unidom::Order::Placer::Mock',
      taker_id:         SecureRandom.uuid,
      taker_type:       'Unidom::Order::Taker::Mock',
      number:           '202001019527',
      purchase_amount:  10.00,
      aggregate_amount: 12.00
    }

    it_behaves_like 'belongs_to', model_attributes, :order, Unidom::Order::Order, order_attributes

    it_behaves_like 'monomorphic scope', model_attributes, :order_is, :order

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
unidom-order-2.0.1 lib/rspec/models/unidom/order/order_item_spec.rb
unidom-order-2.0 lib/rspec/models/unidom/order/order_item_spec.rb
unidom-order-1.5.9 lib/rspec/models/unidom/order/order_item_spec.rb
unidom-order-1.5.8 lib/rspec/models/unidom/order/order_item_spec.rb
unidom-order-1.5.7 lib/rspec/models/unidom/order/order_item_spec.rb
unidom-order-1.5.6 lib/rspec/models/unidom/order/order_item_spec.rb
unidom-order-1.5.5 lib/rspec/models/unidom/order/order_item_spec.rb