Sha256: f17794d80c7a8e32e60336c2d33b8310e8dc3f219072605a74818a5b788c950d

Contents?: true

Size: 1.99 KB

Versions: 1

Compression:

Stored size: 1.99 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', model_attributes, :quantity,
      {                               } => 0,
      { quantity: nil                 } => 2,
      { quantity: ''                  } => 2,
      { quantity: '1'                 } => 0,
      { quantity: 1                   } => 0,
      { quantity: 'A'                 } => 1,
      { quantity: '1.23'              } => 0,
      { quantity: 1.23                } => 0,
      { quantity: '-0.01'             } => 1,
      { quantity: -0.01               } => 1,
      { quantity: '0'                 } => 0,
      { quantity: 0                   } => 0,
      { quantity: '0.01'              } => 0,
      { quantity: 0.01                } => 0,
      { quantity: '999_999_999.99'    } => 0,
      { quantity: 999_999_999.99      } => 0,
      { quantity: '1_000_000_000'     } => 1,
      { quantity: 1_000_000_000       } => 1,
      { quantity: '1_000_000_000.01'  } => 1,
      { quantity: 1_000_000_000.01    } => 1

    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

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unidom-product-1.7.2 lib/rspec/models/unidom/product/product_associating_spec.rb