Render SDG content sidebar when sdg feature setting is enabled

This commit is contained in:
taitus
2020-11-11 19:46:06 +01:00
committed by Javi Martín
parent 72e64bd543
commit cb63185837
4 changed files with 37 additions and 1 deletions

View File

@@ -1,4 +1,7 @@
class SDGManagement::BaseController < ApplicationController
include FeatureFlags
feature_flag :sdg
layout "admin"
before_action :authenticate_user!

View File

@@ -33,7 +33,7 @@
</li>
<% end %>
<% if current_user.administrator? %>
<% if feature?(:sdg) && current_user.administrator? %>
<li>
<%= link_to t("sdg_management.header.title"), sdg_management_root_path %>
</li>

View File

@@ -5,6 +5,8 @@ describe "Goals", :js do
describe "Index" do
scenario "Visit the index" do
Setting["feature.sdg"] = true
visit sdg_management_root_path
within("#side_menu") do

View File

@@ -0,0 +1,31 @@
require "rails_helper"
describe "SDG Management" do
before { login_as(create(:administrator).user) }
context "SDG feature flag is enabled", :js do
before { Setting["feature.sdg"] = true }
scenario "shows the SDG content link" do
visit root_path
click_link "Menu"
expect(page).to have_link "SDG content"
end
end
context "SDG feature is disabled" do
before { Setting["feature.sdg"] = false }
scenario "does not show the SDG Content link", :js do
visit root_path
click_link "Menu"
expect(page).not_to have_link "SDG content"
end
scenario "does not allow visits to the SDG content" do
expect { visit sdg_management_root_path }.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
end