Sha256: f6b47e5f9f62bb1799b79463d34f6296d9ee6d572cd357fb6fb6bcc232b3708c

Contents?: true

Size: 1.88 KB

Versions: 1

Compression:

Stored size: 1.88 KB

Contents

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

  before :each do
  end

  after :each do
  end

  context do

    model_attributes = {
      adjusted_id:            SecureRandom.uuid,
      adjusted_type:          'Unidom::Order::Adjusted::Mock',
      adjustment_factor_code: Unidom::Order::AdjustmentFactor::DISCOUNT_ADJUSTMENT.code,
      calculation_code:       'AMNT',
      amount:                 10.00
    }

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

    it_behaves_like 'validates numericality', model_attributes, :amount,
      range: -1_000_000_000..1_000_000_000, minimum_inclusive: true,  maximum_inclusive: true

    it_behaves_like 'ProgneTapera::EnumCode', described_class.new(model_attributes), :adjustment_factor, Unidom::Order::AdjustmentFactor

    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
    }

    order_item_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 'belongs_to', model_attributes, :adjusted, Unidom::Order::Order,     order_attributes
    it_behaves_like 'belongs_to', model_attributes, :adjusted, Unidom::Order::OrderItem, order_item_attributes

    it_behaves_like 'polymorphic scope', model_attributes, :adjusted_is, :adjusted, [ Unidom::Order::Order, Unidom::Order::OrderItem ]

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unidom-order-1.5.5 lib/rspec/models/unidom/order/order_adjustment_spec.rb