Files
nairobi/spec/features/admin/feature_flags_spec.rb
rgarcia bb3c4c6399 adds consistency to ruby code style
Keep a blank line before and after private
Keep a blank line before and after protected
Remove extra empty line at class body end
Remove extra blank line
Add final newline
Use 2 (not 3) spaces for indentation
Use 2 (not 4) spaces for indentation
Remove space before comma
Add space after comma
Remove trailing whitespaces
Remove unnecessary spacing
Use snake_case for variable names
Do not use then for multi-line if
Remove unused block argument - i
Use the new Ruby 1.9 hash syntax
Remove unused assignment to variable
Indent when as deep as case
Align attributes
Align end with def
2016-11-15 11:18:43 +01:00

64 lines
1.6 KiB
Ruby

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 "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 "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