diff --git a/app/models/space.rb b/app/models/space.rb
index 0398ac1d4..45dabfaba 100644
--- a/app/models/space.rb
+++ b/app/models/space.rb
@@ -1,5 +1,5 @@
class Space < ApplicationRecord
- FEATURES = %w[events materials elearning_materials learning_paths workflows collections trainers content_providers nodes].freeze
+ FEATURES = %w[events materials elearning_materials learning_paths workflows collections trainers content_providers nodes spaces].freeze
include PublicActivity::Common
include LogParameterChanges
diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb
index ae0edf198..939537e2f 100644
--- a/app/views/layouts/_footer.html.erb
+++ b/app/views/layouts/_footer.html.erb
@@ -27,6 +27,11 @@
+ <% if TeSS::Config.feature['spaces'] %>
+
+ <% end %>
diff --git a/app/views/static/home/_counters.html.erb b/app/views/static/home/_counters.html.erb
index 789f4f997..508a50a07 100644
--- a/app/views/static/home/_counters.html.erb
+++ b/app/views/static/home/_counters.html.erb
@@ -1,5 +1,5 @@
<% features ||= ['events', 'materials', 'workflows', 'learning_paths', 'trainers'] %>
-<% features = features.select { |f| TeSS::Config.feature[f] } %>
+<% features = features.select { |f| feature_enabled?(f) } %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index da4d12a36..1c39f7212 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -853,6 +853,7 @@ en:
funding: Funding & acknowledgements
privacy: Privacy
cookie_preferences: Cookie preferences
+ browse_spaces: Browse Spaces
version: 'Version:'
source_code: Source code
api_documentation: API documentation
diff --git a/test/controllers/spaces_controller_test.rb b/test/controllers/spaces_controller_test.rb
index c33445860..db95ce642 100644
--- a/test/controllers/spaces_controller_test.rb
+++ b/test/controllers/spaces_controller_test.rb
@@ -246,6 +246,7 @@ class SpacesControllerTest < ActionController::TestCase
'elearning_materials': false,
'learning_paths': false,
'workflows': true,
+ 'spaces': true,
'collections': false,
'content_providers': false,
'trainers': false,
@@ -255,7 +256,7 @@ class SpacesControllerTest < ActionController::TestCase
with_settings(feature: features) do
get :edit, params: { id: @space }
assert_response :success
- assert_select '[name="space[enabled_features][]"]', count: 3 # +1 because of the blank input that allows you to
+ assert_select '[name="space[enabled_features][]"]', count: 4 # +1 because of the blank input that allows you to
# clear the list
assert_select '#space_enabled_features_events', count: 1
assert_select '#space_enabled_features_workflows', count: 1
diff --git a/test/controllers/static_controller_test.rb b/test/controllers/static_controller_test.rb
index 4c89cdaab..266208138 100644
--- a/test/controllers/static_controller_test.rb
+++ b/test/controllers/static_controller_test.rb
@@ -712,4 +712,31 @@ class StaticControllerTest < ActionController::TestCase
end
end
end
+
+ test 'disabled features do not show as counters on space front page' do
+ space = spaces(:plants)
+ space.disabled_features = ['materials']
+ space.save!
+
+ with_host('plants.mytess.training') do
+ get :home
+ end
+
+ assert_select '.resource-counter a[href=?]', materials_path, count: 0
+ assert_select '.resource-counter a[href=?]', events_path, count: 1
+ end
+
+ test 'can disable spaces index from directory, but it still shows up in the footer' do
+ space = spaces(:plants)
+ space.disabled_features = ['spaces']
+ space.save!
+
+ with_settings(feature: { 'events': false }) do
+ with_host('plants.mytess.training') do
+ get :home
+ assert_select 'ul.nav.navbar-nav li a[href=?]', spaces_path, count: 0
+ assert_select '.footer-item a[href=?]', spaces_path, count: 1
+ end
+ end
+ end
end