<commit_before>require 'rails_helper'

feature 'Admin feature flags' do

  background do
    login_as(create(:administrator).user)
  end

  scenario 'Enabled features are listed on menu' do
    visit admin_root_path

    within('#side_menu') do
      expect(page).to have_link "Spending proposals"
      expect(page).to have_link "Hidden debates"
    end
  end

  scenario 'Disable a feature' do
    setting_id = Setting.find_by(key: 'feature.spending_proposals').id

    visit admin_settings_path

    within("#edit_setting_#{setting_id}") do
      expect(page).to have_button "Disable"
      expect(page).to_not have_button "Enable"
      click_button 'Disable'
    end

    visit admin_root_path

    within('#side_menu') do
      expect(page).not_to have_link "Budgets"
    end

    expect{ visit spending_proposals_path }.to raise_exception(FeatureFlags::FeatureDisabled)
    expect{ visit admin_spending_proposals_path }.to raise_exception(FeatureFlags::FeatureDisabled)
  end

  scenario 'Enable a disabled feature' do
    Setting['feature.spending_proposals'] = nil
    setting_id = Setting.find_by(key: 'feature.spending_proposals').id

    visit admin_root_path

    within('#side_menu') do
      expect(page).not_to have_link "Budgets"
    end

    visit admin_settings_path

    within("#edit_setting_#{setting_id}") do
      expect(page).to have_button "Enable"
      expect(page).to_not have_button "Disable"
      click_button 'Enable'
    end

    visit admin_root_path

    within('#side_menu') do
      expect(page).to have_link "Spending proposals"
    end
  end
end<commit_msg>adds extra expectations to spec<commit_after>require 'rails_helper'

feature 'Admin feature flags' do

  background do
    login_as(create(:administrator).user)
  end

  scenario 'Enabled features are listed on menu' do
    visit admin_root_path

    within('#side_menu') do
      expect(page).to have_link "Spending proposals"
      expect(page).to have_link "Hidden debates"
    end
  end

  scenario 'Disable a feature' do
    setting_id = Setting.find_by(key: 'feature.spending_proposals').id

    visit admin_settings_path

    within("#edit_setting_#{setting_id}") do
      expect(page).to have_button "Disable"
      expect(page).to_not have_button "Enable"
      click_button 'Disable'
    end

    visit admin_root_path

    within('#side_menu') do
      expect(page).not_to have_link "Budgets"
      expect(page).not_to have_link "Spending proposals"
    end

    expect{ visit spending_proposals_path }.to raise_exception(FeatureFlags::FeatureDisabled)
    expect{ visit admin_spending_proposals_path }.to raise_exception(FeatureFlags::FeatureDisabled)
  end

  scenario 'Enable a disabled feature' do
    Setting['feature.spending_proposals'] = nil
    setting_id = Setting.find_by(key: 'feature.spending_proposals').id

    visit admin_root_path

    within('#side_menu') do
      expect(page).not_to have_link "Budgets"
      expect(page).not_to have_link "Spending proposals"
    end

    visit admin_settings_path

    within("#edit_setting_#{setting_id}") do
      expect(page).to have_button "Enable"
      expect(page).to_not have_button "Disable"
      click_button 'Enable'
    end

    visit admin_root_path

    within('#side_menu') do
      expect(page).to have_link "Spending proposals"
    end
  end
end
{'fraction_non_alphanumeric': 0.08839446782922429, 'fraction_numerical': 0.0, 'mean_word_length': 3.8147612156295225, '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': '5819218', 'n_tokens_mistral': 1042, 'n_tokens_neox': 1015, 'n_words': 243}