<commit_before>describe Unidom::Order::Order, type: :model do

  before :each do
  end

  after :each do
  end

  context do

    model_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
    }

    number_length = described_class.columns_hash['number'].limit

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

    it_behaves_like 'validates', model_attributes, :number,
      {             } => 0,
      { number: nil } => 2,
      { number: ''  } => 2,
      { number: '1' } => 1,
      { number: 'A' } => 1,
      { number: '9'*(number_length-1) } => 1,
      { number: 'A'*(number_length-1) } => 1,
      { number: '9'*number_length     } => 0,
      { number: 'A'*number_length     } => 0,
      { number: '9'*(number_length+1) } => 1,
      { number: 'A'*(number_length+1) } => 1

    it_behaves_like 'validates', model_attributes, :purchase_amount,
      {                                     } => 0,
      { purchase_amount: nil                } => 2,
      { purchase_amount: ''                 } => 2,
      { purchase_amount: '1'                } => 0,
      { purchase_amount: 1                  } => 0,
      { purchase_amount: 'A'                } => 1,
      { purchase_amount: '1.23'             } => 0,
      { purchase_amount: 1.23               } => 0,
      { purchase_amount: '-0.01'            } => 1,
      { purchase_amount: -0.01              } => 1,
      { purchase_amount: '0'                } => 1,
      { purchase_amount: 0                  } => 1,
      { purchase_amount: '0.01'             } => 0,
      { purchase_amount: 0.01               } => 0,
      { purchase_amount: '999_999_999.99'   } => 0,
      { purchase_amount: 999_999_999.99     } => 0,
      { purchase_amount: '1_000_000_000'    } => 1,
      { purchase_amount: 1_000_000_000      } => 1,
      { purchase_amount: '1_000_000_000.01' } => 1,
      { purchase_amount: 1_000_000_000.01   } => 1

    it_behaves_like 'validates', model_attributes, :aggregate_amount,
      {                                      } => 0,
      { aggregate_amount: nil                } => 2,
      { aggregate_amount: ''                 } => 2,
      { aggregate_amount: '1'                } => 0,
      { aggregate_amount: 1                  } => 0,
      { aggregate_amount: 'A'                } => 1,
      { aggregate_amount: '1.23'             } => 0,
      { aggregate_amount: 1.23               } => 0,
      { aggregate_amount: '-0.01'            } => 1,
      { aggregate_amount: -0.01              } => 1,
      { aggregate_amount: '0'                } => 1,
      { aggregate_amount: 0                  } => 1,
      { aggregate_amount: '0.01'             } => 0,
      { aggregate_amount: 0.01               } => 0,
      { aggregate_amount: '999_999_999.99'   } => 0,
      { aggregate_amount: 999_999_999.99     } => 0,
      { aggregate_amount: '1_000_000_000'    } => 1,
      { aggregate_amount: 1_000_000_000      } => 1,
      { aggregate_amount: '1_000_000_000.01' } => 1,
      { aggregate_amount: 1_000_000_000.01   } => 1

  end

end<commit_msg>1, Improve the Order spec for the ``has_many :items, class_name: 'Unidom::Order::OrderItem'`` macro.<commit_after>describe Unidom::Order::Order, type: :model do

  before :each do
  end

  after :each do
  end

  context do

    model_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
    }

    number_length = described_class.columns_hash['number'].limit

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

    it_behaves_like 'validates', model_attributes, :number,
      {             } => 0,
      { number: nil } => 2,
      { number: ''  } => 2,
      { number: '1' } => 1,
      { number: 'A' } => 1,
      { number: '9'*(number_length-1) } => 1,
      { number: 'A'*(number_length-1) } => 1,
      { number: '9'*number_length     } => 0,
      { number: 'A'*number_length     } => 0,
      { number: '9'*(number_length+1) } => 1,
      { number: 'A'*(number_length+1) } => 1

    it_behaves_like 'validates', model_attributes, :purchase_amount,
      {                                     } => 0,
      { purchase_amount: nil                } => 2,
      { purchase_amount: ''                 } => 2,
      { purchase_amount: '1'                } => 0,
      { purchase_amount: 1                  } => 0,
      { purchase_amount: 'A'                } => 1,
      { purchase_amount: '1.23'             } => 0,
      { purchase_amount: 1.23               } => 0,
      { purchase_amount: '-0.01'            } => 1,
      { purchase_amount: -0.01              } => 1,
      { purchase_amount: '0'                } => 1,
      { purchase_amount: 0                  } => 1,
      { purchase_amount: '0.01'             } => 0,
      { purchase_amount: 0.01               } => 0,
      { purchase_amount: '999_999_999.99'   } => 0,
      { purchase_amount: 999_999_999.99     } => 0,
      { purchase_amount: '1_000_000_000'    } => 1,
      { purchase_amount: 1_000_000_000      } => 1,
      { purchase_amount: '1_000_000_000.01' } => 1,
      { purchase_amount: 1_000_000_000.01   } => 1

    it_behaves_like 'validates', model_attributes, :aggregate_amount,
      {                                      } => 0,
      { aggregate_amount: nil                } => 2,
      { aggregate_amount: ''                 } => 2,
      { aggregate_amount: '1'                } => 0,
      { aggregate_amount: 1                  } => 0,
      { aggregate_amount: 'A'                } => 1,
      { aggregate_amount: '1.23'             } => 0,
      { aggregate_amount: 1.23               } => 0,
      { aggregate_amount: '-0.01'            } => 1,
      { aggregate_amount: -0.01              } => 1,
      { aggregate_amount: '0'                } => 1,
      { aggregate_amount: 0                  } => 1,
      { aggregate_amount: '0.01'             } => 0,
      { aggregate_amount: 0.01               } => 0,
      { aggregate_amount: '999_999_999.99'   } => 0,
      { aggregate_amount: 999_999_999.99     } => 0,
      { aggregate_amount: '1_000_000_000'    } => 1,
      { aggregate_amount: 1_000_000_000      } => 1,
      { aggregate_amount: '1_000_000_000.01' } => 1,
      { aggregate_amount: 1_000_000_000.01   } => 1

    order_item_1_attributes = {
      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
    }

    order_item_2_attributes = {
      ordered_id:      SecureRandom.uuid,
      ordered_type:    'Unidom::Order::Ordered::Mock',
      placer_id:       SecureRandom.uuid,
      placer_type:     'Unidom::Order::Placer::Mock',
      ordinal:         2,
      unit_price:      20.00,
      quantity:        24.00,
      purchase_amount: 480.00,
      subtotal_amount: 400.00
    }

    it_behaves_like 'has_many', model_attributes, :items, Unidom::Order::OrderItem, [ order_item_1_attributes, order_item_2_attributes ]

  end

end
{'fraction_non_alphanumeric': 0.1411042944785276, 'fraction_numerical': 0.07218378801723013, 'mean_word_length': 1.6230742896268402, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 105, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '35', 'n_tokens_mistral': 2912, 'n_tokens_neox': 2492, 'n_words': 441}