Sha256: f2c61c23c386a5ca9cc19d5cbea9724aa4196aceda255864b7525269eeab4f1b

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 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

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

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