<commit_before><commit_msg>rename and slight refactor of audit trail integration test<commit_after>require 'test_helper'

class AuditTrailLoggingTest < ActionDispatch::IntegrationTest
  def setup
    @user = create :user, email: "<EMAIL>"
    @user2 = create :user, email: "<EMAIL>"
    log_in_as @user
    @patient = create :patient, name: "tester", primary_phone: "1231231234"
    @pregnancy = create :pregnancy, appointment_date: nil, patient: @patient
    visit edit_pregnancy_path(@pregnancy)
  end

  describe 'A patient was created at some point' do
    it 'posts changes and verifies audit trail in db' do
      assert_equal @patient.history_tracks.count , 1
      assert_equal @patient.created_by, @user
      assert_equal page.find(:id, 'pregnancy_patient_name').value, "tester"
      fill_in "Name", with: "changed"
      click_button "TEMP: SAVE INFORMATION"
      @patient.reload
      assert_equal @patient.name, "changed"
      assert_equal @patient.history_tracks.count, 2
      assert_equal @patient.updated_by, @user
      sign_out
      log_in_as @user2
      visit edit_pregnancy_path(@pregnancy)
      assert_equal page.find(:id, 'pregnancy_patient_name').value, "changed"
      fill_in "Name", with: "<NAME>"
      click_button "TEMP: SAVE INFORMATION"
      @patient.reload
      assert_equal @patient.name, "more change"
      assert_equal @patient.history_tracks.count, 3
      assert_equal @patient.updated_by, @user2
    end
  end
end
{'fraction_non_alphanumeric': 0.09582477754962354, 'fraction_numerical': 0.010951403148528405, 'mean_word_length': 3.857142857142857, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, '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': '6531157', 'n_tokens_mistral': 477, 'n_tokens_neox': 447, 'n_words': 122}