Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/space.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions app/views/layouts/_footer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
<div class="footer-item">
<%= link_to t('footer.about', title: TeSS::Config.site['title_short']), about_path %>
</div>
<% if TeSS::Config.feature['spaces'] %>
<div class="footer-item">
<%= link_to t('footer.browse_spaces'), spaces_path %>
</div>
<% end %>
<div class="footer-item">
<%= link_to t('footer.funding'), us_path(anchor: 'funding') %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/static/home/_counters.html.erb
Original file line number Diff line number Diff line change
@@ -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) } %>

<section id="counters">
<ul class="counter">
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/controllers/spaces_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
27 changes: 27 additions & 0 deletions test/controllers/static_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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