<commit_before>require 'rails_helper'

feature 'Admin administrators' do
  background do
    @admin = create(:administrator)
    @user  = create(:user, username: '<NAME>')
    @administrator = create(:administrator)
    login_as(@admin.user)
    visit admin_administrators_path
  end

  scenario 'Index' do
    expect(page).to have_content @administrator.name
    expect(page).to have_content @administrator.email
    expect(page).to_not have_content @user.name
  end

  scenario 'Create Administrator', :js do
    fill_in 'email', with: @user.email
    click_button 'Search'

    expect(page).to have_content @user.name
    click_link 'Add'
    within("#administrators") do
      expect(page).to have_content @user.name
    end
  end

  scenario 'Delete Administrator' do
    find(:xpath, "//tr[contains(.,'#{@administrator.name}')]/td/a", text: 'Delete').click

    within("#administrators") do
      expect(page).to_not have_content @administrator.name
    end
  end
end
<commit_msg>Add spec scenario for current user trying to remove himself from administrators list<commit_after>require 'rails_helper'

feature 'Admin administrators' do
  background do
    @admin = create(:administrator)
    @user  = create(:user, username: '<NAME>')
    @administrator = create(:administrator)
    login_as(@admin.user)
    visit admin_administrators_path
  end

  scenario 'Index' do
    expect(page).to have_content @administrator.name
    expect(page).to have_content @administrator.email
    expect(page).to_not have_content @user.name
  end

  scenario 'Create Administrator', :js do
    fill_in 'email', with: @user.email
    click_button 'Search'

    expect(page).to have_content @user.name
    click_link 'Add'
    within("#administrators") do
      expect(page).to have_content @user.name
    end
  end

  scenario 'Delete Administrator' do
    find(:xpath, "//tr[contains(.,'#{@administrator.name}')]/td/a", text: 'Delete').click

    within("#administrators") do
      expect(page).to_not have_content @administrator.name
    end
  end

  scenario 'Delete Administrator when its the current user' do
    find(:xpath, "//tr[contains(.,'#{@admin.name}')]/td/a", text: 'Delete').click

    within("#error") do
      expect(page).to have_content I18n.t("admin.administrators.administrator.restricted_removal")
    end
  end
end

{'fraction_non_alphanumeric': 0.12118607649333907, 'fraction_numerical': 0.0008594757198109154, 'mean_word_length': 3.9850107066381155, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6804371', 'n_tokens_mistral': 724, 'n_tokens_neox': 708, 'n_words': 176}