<commit_before>require 'rails_helper'

feature 'respond to drafter assignment' do

  given(:drafter)         { create(:user, roles: ['drafter']) }

  given(:kase)  do
    create(
      :assigned_case,
      subject: 'A message about XYZ',
      message: 'I would like to know about XYZ'
    )
  end

  given(:assignment) do
    kase.assignments.detect(&:drafter?)
  end

  background do
    login_as drafter
  end

  scenario 'kilo accepts assignment' do
    visit edit_case_assignment_path kase, assignment
    expect(page).to have_content kase.name
    expect(page).to have_content 'A message about XYZ'
    expect(page).to have_content 'I would like to know about XYZ'

    choose 'Accept'
    expect(page).to have_selector('#assignment_reasons_for_rejection', visible: false)
    click_button 'Confirm'

    expect(current_path).to eq case_path kase
    expect(assignment.reload.state).to eq 'accepted'
    expect(kase.reload.current_state).to eq 'drafting'
  end

  scenario 'kilo rejects assignment' do
    visit edit_case_assignment_path kase, assignment
    expect(page).to have_content kase.name
    expect(page).to have_content 'A message about XYZ'
    expect(page).to have_content 'I would like to know about XYZ'

    choose 'Reject'
    expect(page).to have_selector('#assignment_reasons_for_rejection', visible: true)
    fill_in 'Reason for rejecting this case', with: 'I am not the correct KILO for this'
    click_button 'Confirm'
 
    expect(current_path).to eq case_path kase
    expect(Assignment.exists?(assignment.id)).to be false
    expect(kase.reload.current_state).to eq 'unassigned'
  end
end<commit_msg>Test Case number and Subject are on the page<commit_after>require 'rails_helper'

feature 'respond to drafter assignment' do

  given(:drafter)         { create(:user, roles: ['drafter']) }

  given(:kase)  do
    create(
      :assigned_case,
      subject: 'A message about XYZ',
      message: 'I would like to know about XYZ'
    )
  end

  given(:assignment) do
    kase.assignments.detect(&:drafter?)
  end

  background do
    login_as drafter
  end

  scenario 'kilo accepts assignment' do
    visit edit_case_assignment_path kase, assignment
    expect(page).to have_content kase.number
    expect(page).to have_content kase.subject
    expect(page).to have_content 'A message about XYZ'
    expect(page).to have_content 'I would like to know about XYZ'

    choose 'Accept'
    expect(page).to have_selector('#assignment_reasons_for_rejection', visible: false)
    click_button 'Confirm'

    expect(current_path).to eq case_path kase
    expect(assignment.reload.state).to eq 'accepted'
    expect(kase.reload.current_state).to eq 'drafting'
  end

  scenario 'kilo rejects assignment' do
    visit edit_case_assignment_path kase, assignment
    expect(page).to have_content kase.number
    expect(page).to have_content kase.subject
    expect(page).to have_content 'A message about XYZ'
    expect(page).to have_content 'I would like to know about XYZ'

    choose 'Reject'
    expect(page).to have_selector('#assignment_reasons_for_rejection', visible: true)
    fill_in 'Reason for rejecting this case', with: 'I am not the correct KILO for this'
    click_button 'Confirm'

    expect(current_path).to eq case_path kase
    expect(Assignment.exists?(assignment.id)).to be false
    expect(kase.reload.current_state).to eq 'unassigned'
  end

  scenario 'kilo rejects assignment but provides no reasons for rejection' do
    visit edit_case_assignment_path kase, assignment
    expect(page).to have_content kase.number
    expect(page).to have_content kase.subject
    expect(page).to have_content 'A message about XYZ'
    expect(page).to have_content 'I would like to know about XYZ'

    choose 'Reject'
    expect(page).
      to have_selector('#assignment_reasons_for_rejection', visible: true)
    click_button 'Confirm'

    expect(page.find('#assignment_state_rejected')).to be_checked
    expect(page).
      to have_selector('#assignment_reasons_for_rejection', visible: true)
    expect(kase.reload.current_state).to eq 'awaiting_responder'

    expect(page).
      to have_content("Reason for rejecting this case can't be blank")
  end
end
{'fraction_non_alphanumeric': 0.08885183420676512, 'fraction_numerical': 0.0, 'mean_word_length': 3.9284037558685445, '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': '4826288', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1292, 'n_words': 373}