Sha256: 1becf44411c5e10130457085709912b43861b5105b6fe7c4f83cfc8d4f27a85f

Contents?: true

Size: 1.34 KB

Versions: 6

Compression:

Stored size: 1.34 KB

Contents

describe Unidom::Product::ProductAssociating, type: :model do

  before :each do
  end

  after :each do
  end

  context do

    model_attributes = {
      source_id:                SecureRandom.uuid,
      target_id:                SecureRandom.uuid,
      product_association_code: Unidom::Product::ProductAssociation::COMPLEMENT.code,
      ordinal:                  1,
      quantity:                 2
    }

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

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

    it_behaves_like 'ProgneTapera::EnumCode', described_class.new(model_attributes), :product_association, Unidom::Product::ProductAssociation

    product_attributes = {
      name:             'Model X',
      abbreviation:     'MX',
      measurement_unit: 'car',
      packing_norm:     '1 car',
      formset_code:     'WARE'
    }

    it_behaves_like 'belongs_to', model_attributes, :source, Unidom::Product::Product, product_attributes
    it_behaves_like 'belongs_to', model_attributes, :target, Unidom::Product::Product, product_attributes

    it_behaves_like 'monomorphic scope', model_attributes, :source_is, :source
    it_behaves_like 'monomorphic scope', model_attributes, :target_is, :target

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
unidom-product-2.0 lib/rspec/models/unidom/product/product_associating_spec.rb
unidom-product-1.7.8 lib/rspec/models/unidom/product/product_associating_spec.rb
unidom-product-1.7.7 lib/rspec/models/unidom/product/product_associating_spec.rb
unidom-product-1.7.6 lib/rspec/models/unidom/product/product_associating_spec.rb
unidom-product-1.7.5 lib/rspec/models/unidom/product/product_associating_spec.rb
unidom-product-1.7.4 lib/rspec/models/unidom/product/product_associating_spec.rb