diff --git a/dashboard/test/integration/user_menu_test.rb b/dashboard/test/integration/user_menu_test.rb index d985fc3c37581..2605f2e3fe8ae 100644 --- a/dashboard/test/integration/user_menu_test.rb +++ b/dashboard/test/integration/user_menu_test.rb @@ -53,10 +53,22 @@ def open_pairing_test(show_pairing) assert_select 'a[href="//test-studio.code.org/users/sign_out"]', 'Sign out' end - test 'show link to pair programming when in a section' do + test "don't show link to pair programming when not in a section" do + student = create(:student) + sign_in student + + get '/home' + + assert_response :success + assert_select 'a[href="http://test.host/pairing"]', false + end + + test 'show link to pair programming when in a section that has pairing enabled' do student = create(:follower).student_user sign_in student + section = student.sections_as_student.first + assert section.pairing_allowed? assert student.can_pair? get '/home' @@ -65,9 +77,19 @@ def open_pairing_test(show_pairing) assert_select '#pairing_link' end - test "don't show link to pair programming when not in a section" do - student = create(:student) + test "don't show link to pair programming when in a section that has pairing disabled" do + student = create(:follower).student_user sign_in student + section = student.sections_as_student.first + + assert section.pairing_allowed? + assert student.can_pair? + + section.update!(pairing_allowed: false) + student.reload + + refute section.pairing_allowed? + refute student.can_pair? get '/home'