Files
grecia/spec/features/admin/feature_flags_spec.rb
Javi Martín db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00

105 lines
2.7 KiB
Ruby

require "rails_helper"
describe "Admin feature flags" do
before do
Setting["process.budgets"] = true
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 "Participatory budgets"
expect(page).to have_link "Hidden debates"
end
end
scenario "Disable a participatory process" do
setting = Setting.find_by(key: "process.budgets")
budget = create(:budget)
visit admin_settings_path
within("#settings-tabs") { click_link "Participation processes" }
within("#edit_setting_#{setting.id}") do
expect(page).to have_button "Disable"
expect(page).not_to have_button "Enable"
click_button "Disable"
end
visit admin_root_path
within("#side_menu") do
expect(page).not_to have_link "Participatory budgets"
end
expect { visit budget_path(budget) }.to raise_exception(FeatureFlags::FeatureDisabled)
expect { visit admin_budgets_path }.to raise_exception(FeatureFlags::FeatureDisabled)
end
scenario "Enable a disabled participatory process" do
Setting["process.budgets"] = nil
setting = Setting.find_by(key: "process.budgets")
visit admin_root_path
within("#side_menu") do
expect(page).not_to have_link "Participatory budgets"
end
visit admin_settings_path
within("#settings-tabs") { click_link "Participation processes" }
within("#edit_setting_#{setting.id}") do
expect(page).to have_button "Enable"
expect(page).not_to have_button "Disable"
click_button "Enable"
end
visit admin_root_path
within("#side_menu") do
expect(page).to have_link "Participatory budgets"
end
end
scenario "Disable a feature" do
setting = Setting.find_by(key: "feature.twitter_login")
visit admin_settings_path
within("#edit_setting_#{setting.id}") do
expect(page).to have_button "Disable"
expect(page).not_to have_button "Enable"
click_button "Disable"
end
expect(page).to have_content "Value updated"
within("#edit_setting_#{setting.id}") do
expect(page).to have_button "Enable"
expect(page).not_to have_button "Disable"
end
end
scenario "Enable a disabled feature" do
setting = Setting.find_by(key: "feature.map")
visit admin_settings_path
within("#edit_setting_#{setting.id}") do
expect(page).to have_button "Enable"
expect(page).not_to have_button "Disable"
click_button "Enable"
end
expect(page).to have_content "Value updated"
within("#edit_setting_#{setting.id}") do
expect(page).to have_button "Disable"
expect(page).not_to have_button "Enable"
end
end
end