@@ -520,4 +520,178 @@ class StaticControllerTest < ActionController::TestCase
520520 end
521521 end
522522 end
523+
524+ test 'should respect space disabled_features when displaying tabs' do
525+ space = spaces ( :plants )
526+ space . disabled_features = [ 'events' , 'materials' ]
527+ space . save!
528+
529+ features = {
530+ 'events' : true ,
531+ 'materials' : true ,
532+ 'elearning_materials' : true ,
533+ 'workflows' : true ,
534+ 'collections' : true ,
535+ 'content_providers' : true ,
536+ 'trainers' : true ,
537+ 'nodes' : true ,
538+ 'spaces' : true
539+ }
540+
541+ with_settings ( feature : features ) do
542+ with_host ( 'plants.mytess.training' ) do
543+ get :home
544+
545+ # These should NOT appear because they're disabled for this space
546+ assert_select 'ul.nav.navbar-nav' do
547+ assert_select 'li a[href=?]' , events_path , count : 0
548+ assert_select 'li a[href=?]' , materials_path , count : 0
549+ end
550+
551+ # These should still appear because they're not disabled
552+ assert_select 'ul.nav.navbar-nav' do
553+ assert_select 'li a[href=?]' , about_path
554+ assert_select 'li a[href=?]' , elearning_materials_path
555+ assert_select 'li a[href=?]' , workflows_path
556+ assert_select 'li a[href=?]' , collections_path
557+ end
558+ end
559+ end
560+ end
561+
562+ test 'space disabled_features do not affect default space' do
563+ space = spaces ( :plants )
564+ space . disabled_features = [ 'events' , 'materials' ]
565+ space . save!
566+
567+ features = {
568+ 'events' : true ,
569+ 'materials' : true ,
570+ 'elearning_materials' : true ,
571+ 'workflows' : true ,
572+ 'collections' : true ,
573+ 'content_providers' : true ,
574+ 'trainers' : true ,
575+ 'nodes' : true ,
576+ 'spaces' : true
577+ }
578+
579+ with_settings ( feature : features ) do
580+ # Access the default space (not plants)
581+ get :home
582+
583+ # All features should appear in the default space
584+ assert_select 'ul.nav.navbar-nav' do
585+ assert_select 'li a[href=?]' , about_path
586+ assert_select 'li a[href=?]' , events_path
587+ assert_select 'li a[href=?]' , materials_path
588+ assert_select 'li a[href=?]' , elearning_materials_path
589+ assert_select 'li a[href=?]' , workflows_path
590+ assert_select 'li a[href=?]' , collections_path
591+ end
592+ end
593+ end
594+
595+ test 'different spaces can have different disabled features' do
596+ plants_space = spaces ( :plants )
597+ plants_space . disabled_features = [ 'events' ]
598+ plants_space . save!
599+
600+ astro_space = spaces ( :astro )
601+ astro_space . disabled_features = [ 'materials' ]
602+ astro_space . save!
603+
604+ features = {
605+ 'events' : true ,
606+ 'materials' : true ,
607+ 'workflows' : true ,
608+ 'spaces' : true
609+ }
610+
611+ with_settings ( feature : features ) do
612+ # Check plants space - events disabled
613+ with_host ( 'plants.mytess.training' ) do
614+ get :home
615+
616+ assert_select 'ul.nav.navbar-nav' do
617+ assert_select 'li a[href=?]' , events_path , count : 0
618+ assert_select 'li a[href=?]' , materials_path
619+ assert_select 'li a[href=?]' , workflows_path
620+ end
621+ end
622+
623+ # Check astro space - materials disabled
624+ with_host ( 'space.mytess.training' ) do
625+ get :home
626+
627+ assert_select 'ul.nav.navbar-nav' do
628+ assert_select 'li a[href=?]' , events_path
629+ assert_select 'li a[href=?]' , materials_path , count : 0
630+ assert_select 'li a[href=?]' , workflows_path
631+ end
632+ end
633+ end
634+ end
635+
636+ test 'space with no disabled features shows all enabled global features' do
637+ space = spaces ( :plants )
638+ space . disabled_features = [ ]
639+ space . save!
640+
641+ features = {
642+ 'events' : true ,
643+ 'materials' : true ,
644+ 'elearning_materials' : true ,
645+ 'workflows' : true ,
646+ 'collections' : true ,
647+ 'content_providers' : true ,
648+ 'trainers' : true ,
649+ 'nodes' : true ,
650+ 'spaces' : true
651+ }
652+
653+ with_settings ( feature : features ) do
654+ with_host ( 'plants.mytess.training' ) do
655+ get :home
656+
657+ # All globally enabled features should appear
658+ assert_select 'ul.nav.navbar-nav' do
659+ assert_select 'li a[href=?]' , about_path
660+ assert_select 'li a[href=?]' , events_path
661+ assert_select 'li a[href=?]' , materials_path
662+ assert_select 'li a[href=?]' , elearning_materials_path
663+ assert_select 'li a[href=?]' , workflows_path
664+ assert_select 'li a[href=?]' , collections_path
665+ end
666+ end
667+ end
668+ end
669+
670+ test 'space disabled features work with directory tabs' do
671+ space = spaces ( :plants )
672+ space . disabled_features = [ 'content_providers' ]
673+ space . save!
674+
675+ features = {
676+ 'events' : true ,
677+ 'materials' : true ,
678+ 'content_providers' : true ,
679+ 'trainers' : true ,
680+ 'nodes' : true ,
681+ 'spaces' : true
682+ }
683+
684+ with_settings ( feature : features , site : { tab_order : [ ] , directory_tabs : [ 'content_providers' , 'trainers' , 'nodes' ] } ) do
685+ with_host ( 'plants.mytess.training' ) do
686+ get :home
687+
688+ # content_providers should not appear even in directory menu
689+ assert_select 'li.dropdown.directory-menu' do
690+ assert_select 'li a[href=?]' , content_providers_path , count : 0
691+ assert_select 'li a[href=?]' , trainers_path
692+ assert_select 'li a[href=?]' , nodes_path
693+ end
694+ end
695+ end
696+ end
523697end
0 commit comments