From 31498cc414a77fc5b2c554fff282c24edf68fdb0 Mon Sep 17 00:00:00 2001
From: Alex Dusenbery <adusenbery@edx.org>
Date: Tue, 21 Jan 2020 10:29:51 -0500
Subject: [PATCH] In canUserCreateTeam(), look in this.context.userInfo for
 staff/priveleged attributes.

---
 docs/guides/testing/testing.rst               |  2 +-
 .../teams/js/spec/views/topic_teams_spec.js   | 27 ++++++++++++++-----
 .../static/teams/js/views/topic_teams.js      |  4 +--
 3 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/docs/guides/testing/testing.rst b/docs/guides/testing/testing.rst
index 6af957fe683..a7b0825b9a3 100644
--- a/docs/guides/testing/testing.rst
+++ b/docs/guides/testing/testing.rst
@@ -367,7 +367,7 @@ To run JavaScript tests in a browser, run these commands::
 To debug these tests on devstack in a local browser:
 
 * first run the appropriate test_js_dev command from above which will open a browser using XQuartz
-* open http://edx.devstack.lms:19876/debug.html in your host system's browser of choice
+* open http://localhost:19876/debug.html in your host system's browser of choice
 * this will run all the tests and show you the results including details of any failures
 * you can click on an individually failing test and/or suite to re-run it by itself
 * you can now use the browser's developer tools to debug as you would any other JavaScript code
diff --git a/lms/djangoapps/teams/static/teams/js/spec/views/topic_teams_spec.js b/lms/djangoapps/teams/static/teams/js/spec/views/topic_teams_spec.js
index 80e59e0264e..13b385677a5 100644
--- a/lms/djangoapps/teams/static/teams/js/spec/views/topic_teams_spec.js
+++ b/lms/djangoapps/teams/static/teams/js/spec/views/topic_teams_spec.js
@@ -86,23 +86,38 @@ define([
         });
 
         it('does not show actions for a user already in a team', function() {
-            var teamsView = createTopicTeamsView({myTeamsCollection: TeamSpecHelpers.createMockTeams()});
+            var options = {myTeamsCollection: TeamSpecHelpers.createMockTeams()};
+            var teamsView = createTopicTeamsView(options);
             verifyActions(teamsView, {showActions: false});
         });
 
         it('does not show actions for a student in an instructor managed topic', function() {
-            var teamsView = createTopicTeamsView({privileged: false}, true);
+            var teamsView = createTopicTeamsView({}, true);
             verifyActions(teamsView, {showActions: false});
         });
 
         it('shows actions for a privileged user already in a team', function() {
-            var teamsView = createTopicTeamsView({privileged: true});
-            verifyActions(teamsView);
+            var options = {
+                userInfo: {
+                    privileged: true,
+                    staff: false
+                },
+                myTeamsCollection: TeamSpecHelpers.createMockTeams()
+            };
+            var teamsView = createTopicTeamsView(options);
+            verifyActions(teamsView, {showActions: true});
         });
 
         it('shows actions for a staff user already in a team', function() {
-            var teamsView = createTopicTeamsView({privileged: false, staff: true});
-            verifyActions(teamsView);
+            var options = {
+                userInfo: {
+                    privileged: false,
+                    staff: true
+                },
+                myTeamsCollection: TeamSpecHelpers.createMockTeams()
+            };
+            var teamsView = createTopicTeamsView(options);
+            verifyActions(teamsView, {showActions: true});
         });
 
         /*
diff --git a/lms/djangoapps/teams/static/teams/js/views/topic_teams.js b/lms/djangoapps/teams/static/teams/js/views/topic_teams.js
index 19269379b43..a772f730ba5 100644
--- a/lms/djangoapps/teams/static/teams/js/views/topic_teams.js
+++ b/lms/djangoapps/teams/static/teams/js/views/topic_teams.js
@@ -30,8 +30,8 @@
                     // that they create. This means that if multiple team membership is
                     // disabled that they cannot create a new team when they already
                     // belong to one.
-                return this.context.staff
-                    || this.context.privileged
+                return this.context.userInfo.staff
+                    || this.context.userInfo.privileged
                     || (!TeamUtils.isInstructorManagedTopic(this.model.attributes.type)
                         && this.myTeamsCollection.length === 0);
             },
-- 
GitLab