<commit_before>require 'rails_helper'

RSpec.describe 'round editing page', type: :feature do
  before { @tournament = create(:tournament_with_ongoing_third_rounds) }
  let(:page_path) do
    edit_tournament_round_table_path(tournament_id: @tournament.id, round_id: round_number, id: table_number)
  end

  context 'when round is already finished' do
    let(:round_number) { 2 }
    let(:table_number) { 1 }

    it 'redirect to show page' do
      visit page_path
      redirected_oath = tournament_round_table_path(
        tournament_id: @tournament.id, round_id: round_number, id: table_number
      )
      expect(current_path).to eq(redirected_oath)
    end
  end

  context 'when authority level is not "staff"' do
    include_context 'authority level is "guest"'

    let(:round_number) { 3 }
    let(:table_number) { 1 }

    scenario 'click save' do
      visit page_path

      click_on 'Save'

      expect(current_path).to eq(page_path)
      expect(page).to have_css('div', id: 'error_explanation')
    end
  end

  context 'when authority level is "staff"' do
    include_context 'authority level is "staff"'

    let(:round_number) { 3 }
    let(:table_number) { 2 }

    scenario 'input score and click save' do
      visit page_path

      find('#score_1_vp').set('20')
      find('#score_1_has_extra_turn').set(true)
      click_on 'Save'<commit_msg>fix: change wrong expected path<commit_after>require 'rails_helper'

RSpec.describe 'round editing page', type: :feature do
  before { @tournament = create(:tournament_with_ongoing_third_rounds) }
  let(:page_path) do
    edit_tournament_round_table_path(tournament_id: @tournament.id, round_id: round_number, id: table_number)
  end

  context 'when round is already finished' do
    let(:round_number) { 2 }
    let(:table_number) { 1 }

    it 'redirect to show page' do
      visit page_path
      redirected_oath = tournament_round_table_path(
        tournament_id: @tournament.id, round_id: round_number, id: table_number
      )
      expect(current_path).to eq(redirected_oath)
    end
  end

  context 'when authority level is not "staff"' do
    include_context 'authority level is "guest"'

    let(:round_number) { 3 }
    let(:table_number) { 1 }

    scenario 'click save' do
      visit page_path

      click_on 'Save'

      expected_path = tournament_round_table_path(
        tournament_id: @tournament.id, round_id: round_number, id: table_number
      )
      expect(current_path).to eq(expected_path)
      expect(page).to have_css('div', id: 'error_explanation')
    end
  end

  context 'when authority level is "staff"' do
    include_context 'authority level is "staff"'

    let(:round_number) { 3 }
    let(:table_number) { 2 }

    scenario 'input score and click save' do
      visit page_path

      find('#score_1_vp').set('20')
      find('#score_1_has_extra_turn').set(true)
      click_on 'Save'
{'fraction_non_alphanumeric': 0.09824198552223372, 'fraction_numerical': 0.006894174422612892, 'mean_word_length': 3.534375, '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': '2122491', 'n_tokens_mistral': 985, 'n_tokens_neox': 926, 'n_words': 239}