<commit_before>require 'rails_helper'

describe 'finding a participant' do
  let!(:maneuver) { create :maneuver }
  let!(:record_1) do
    create :maneuver_participant,
           :perfect_score, maneuver: maneuver
  end
  let!(:record_2) do
    create :maneuver_participant,
           :perfect_score, maneuver: maneuver
  end
  let!(:record_3) do
    create :maneuver_participant,
           :perfect_score, maneuver: maneuver
  end
  context 'finds the previous' do
    it 'at first participant gets first participant' do
      when_current_user_is :admin
      visit maneuver_participant_path(maneuver.maneuver_participants
        .find_by(id: record_1.id))
      click_link 'Previous participant'
      expect(page).to have_text record_1.participant.name
    end
    it 'at non-first participant redirects to previous' do
      when_current_user_is :admin
      visit maneuver_participant_path(maneuver.maneuver_participants
        .find_by(id: record_2.id))
      click_link 'Previous participant'
      expect(page).to have_text record_1.participant.name
    end
  end
  context 'finds the next' do
    it 'at non-last participant gets next' do
      when_current_user_is :admin
      visit maneuver_participant_path(maneuver.maneuver_participants
        .find_by(id: record_1.id))
      click_link 'Next participant'
      expect(page).to have_text record_2.participant.name
    end
    it 'at last participant redirects to notice' do
      when_current_user_is :admin
      visit maneuver_participant_path(maneuver.maneuver_participants
        .find_by(id: record_3.id))
      click_link 'Next participant'
      expects = 'There are no more participants in the queue for this maneuver.'
      expect(page).to have_text expects
    end
    it 'at last completed participant redirects to new maneuver' do
      create :participant
      when_current_user_is :admin
      visit maneuver_participant_path(maneuver.maneuver_participants
        .find_by(id: record_3.id))
      click_link 'Next participant'<commit_msg>Reduced redundancies in maneuver specs<commit_after>require 'rails_helper'

describe 'finding a participant' do
  let!(:maneuver) { create :maneuver }
  let!(:record_1) do
    create :maneuver_participant,
           :perfect_score, maneuver: maneuver
  end
  let!(:record_2) do
    create :maneuver_participant,
           :perfect_score, maneuver: maneuver
  end
  let!(:record_3) do
    create :maneuver_participant,
           :perfect_score, maneuver: maneuver
  end
  context 'finds the previous' do
    it 'at first participant gets first participant' do
      when_current_user_is :admin
      visit maneuver_participant_path(maneuver.maneuver_participants
        .find_by(id: record_1.id))
      click_link 'Previous participant'
      expects = 'This is the first participant who completed this maneuver.'
      expect(page).to have_text expects
    end
    it 'at non-first participant redirects to previous' do
      when_current_user_is :admin
      visit maneuver_participant_path(maneuver.maneuver_participants
        .find_by(id: record_2.id))
      click_link 'Previous participant'
      expect(page).to have_text record_1.participant.name
    end
  end
  context 'finds the next' do
    it 'at non-last participant gets next' do
      when_current_user_is :admin
      visit maneuver_participant_path(maneuver.maneuver_participants
        .find_by(id: record_1.id))
      click_link 'Next participant'
      expect(page).to have_text record_2.participant.name
    end
    it 'at last participant redirects to notice' do
      when_current_user_is :admin
      visit maneuver_participant_path(maneuver.maneuver_participants
        .find_by(id: record_3.id))
      click_link 'Next participant'
      expects = 'There are no more participants in the queue for this maneuver.'
      expect(page).to have_text expects
    end
    it 'at last completed participant redirects to new maneuver' do
      create :participant
      when_current_user_is :admin
      visit maneuver_participant_path(maneuver.maneuver_participants
        .find_by(id: record_3.id))
      click_link 'Next participant'
{'fraction_non_alphanumeric': 0.06570048309178744, 'fraction_numerical': 0.005072463768115942, 'mean_word_length': 3.410010649627263, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '807761', 'n_tokens_mistral': 1332, 'n_tokens_neox': 1231, 'n_words': 335}