Render SDG content sidebar when sdg feature setting is enabled
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
class SDGManagement::BaseController < ApplicationController
|
||||
include FeatureFlags
|
||||
feature_flag :sdg
|
||||
|
||||
layout "admin"
|
||||
|
||||
before_action :authenticate_user!
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
31
spec/system/sdg_management/sdg_spec.rb
Normal file
31
spec/system/sdg_management/sdg_spec.rb
Normal 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
|
||||
Reference in New Issue
Block a user