@@ -151,6 +151,11 @@ class LearningPathsControllerTest < ActionController::TestCase
151151 get :show , params : { id : @learning_path }
152152 assert_response :success
153153 assert assigns ( :learning_path )
154+ assert_select '.learning-path-topic' , count : 2
155+ assert_operator assigns ( :learning_path ) . topics . length , :> , 1
156+ assert_select '.learning-path-topic.single-topic' , count : 0
157+ refute assigns ( :learning_path ) . unordered?
158+ assert_select '.learning-path-topic.unordered' , count : 0
154159 end
155160
156161 test 'should show learning_path as json' do
@@ -561,4 +566,22 @@ class LearningPathsControllerTest < ActionController::TestCase
561566 assert_equal 'Joe' , lp . authors . first [ :name ]
562567 assert_nil lp . authors . first [ :orcid ]
563568 end
569+
570+ test 'displays single-topic view if only one topic in the learning path' do
571+ get :show , params : { id : learning_paths ( :two ) }
572+ assert_response :success
573+ assert assigns ( :learning_path )
574+ assert_select '.learning-path-topic' , count : 1
575+ assert_select '.learning-path-topic.single-topic' , count : 1
576+ end
577+
578+ test 'displays unordered view when learning path is unordered' do
579+ learning_path = learning_paths ( :one )
580+ learning_path . update! ( unordered : true )
581+ get :show , params : { id : learning_path }
582+ assert_response :success
583+ assert assigns ( :learning_path )
584+ assert assigns ( :learning_path ) . unordered?
585+ assert_select '.learning-path-topic.unordered' , minimum : 1
586+ end
564587end
0 commit comments