<commit_before><commit_msg>Add model tests for Phones (Contact phone numbers)<commit_after>require 'spec_helper'

describe Phone do
  it "does not allow duplicate phone numbers per contact" do
    contact = Contact.create(
      firstname: "John",
      lastname: "Doe",
      email: "<EMAIL>"
      )
    contact.phones.create(
      phone_type: "home",
      phone: "555-555-1234"
      )
    mobile_phone = contact.phones.build(
      phone_type: "mobile",
      phone: "555-555-1234"
      )

    expect(mobile_phone).to have(1).errors_on(:phone)
  end

  it "allows two contacts to share a phone number" do
    john = Contact.create(
      firstname: "John",
      lastname: "Doe",
      email: "<EMAIL>"
      )
    john.phones.create(
      phone_type: "home",
      phone: "555-555-1234"
      )
    jane = Contact.new
    jane_phone = jane.phones.build(
      phone_type: "home",
      phone: "555-555-1234"
      )

    expect(jane_phone).to be_valid
  end
end
{'fraction_non_alphanumeric': 0.11958762886597939, 'fraction_numerical': 0.042268041237113405, 'mean_word_length': 2.467857142857143, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '88144', 'n_tokens_mistral': 354, 'n_tokens_neox': 317, 'n_words': 79}