<commit_before>require 'rails_helper'

RSpec.describe ExitSiteInfection, :type => :model do

  it { should belong_to(:patient) }

  it { should have_many(:medications) }
  it { should have_many(:medication_routes).through(:medications) }
  it { should have_many(:patients).through(:medications) }
  it { should have_many(:infection_organisms) }
  it { should have_many(:organism_codes).through(:infection_organisms) }

  it { should accept_nested_attributes_for(:medications) }
  it { should accept_nested_attributes_for(:infection_organisms) }

  describe "exit site infection" do
    before do
      @patient = create(:patient)
      @es = FactoryGirl.build(:exit_site_infection)
      @lymphocytes = FactoryGirl.create(:organism_code, name: "Lymphocytes")
      @proteus = FactoryGirl.create(:organism_code, name: "Proteus")

      load_drugs_by_type('Cephradine' => ['Antibiotic','Peritonitis'],
                         'Dicloxacillin' => ['Antibiotic','Peritonitis'])

      load_med_routes
    end

    context "medications" do
      it "can be assigned many medications and organisms/sensitivities" do

        @medication_one = FactoryGirl.create(:medication,<commit_msg>Added validation spec test for exit site diagnosis date.<commit_after>require 'rails_helper'

RSpec.describe ExitSiteInfection, :type => :model do

  it { should belong_to(:patient) }

  it { should have_many(:medications) }
  it { should have_many(:medication_routes).through(:medications) }
  it { should have_many(:patients).through(:medications) }
  it { should have_many(:infection_organisms) }
  it { should have_many(:organism_codes).through(:infection_organisms) }

  it { should accept_nested_attributes_for(:medications) }
  it { should accept_nested_attributes_for(:infection_organisms) }

  it { should validate_presence_of :diagnosis_date }

  describe "exit site infection" do
    before do
      @patient = create(:patient)
      @es = FactoryGirl.build(:exit_site_infection)
      @lymphocytes = FactoryGirl.create(:organism_code, name: "Lymphocytes")
      @proteus = FactoryGirl.create(:organism_code, name: "Proteus")

      load_drugs_by_type('Cephradine' => ['Antibiotic','Peritonitis'],
                         'Dicloxacillin' => ['Antibiotic','Peritonitis'])

      load_med_routes
    end

    context "medications" do
      it "can be assigned many medications and organisms/sensitivities" do

        @medication_one = FactoryGirl.create(:medication,
{'fraction_non_alphanumeric': 0.10907610907610908, 'fraction_numerical': 0.0, 'mean_word_length': 4.450110864745011, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3091912', 'n_tokens_mistral': 790, 'n_tokens_neox': 715, 'n_words': 151}