File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -478,6 +478,17 @@ class ScmRouter extends Scm {
478478 _openPr ( config ) {
479479 return this . chooseScm ( config ) . then ( scm => scm . openPr ( config ) ) ;
480480 }
481+
482+ /**
483+ * Check if user belongs to an enterprise
484+ * @method _isEnterpriseUser
485+ * @param {Object } config Configuration
486+ * @param {String } config.scmContext Name of scm context
487+ * @return {Boolean } True if user belongs to an enterprise
488+ */
489+ _isEnterpriseUser ( config ) {
490+ return this . chooseScm ( config ) . then ( scm => scm . isEnterpriseUser ( config ) ) ;
491+ }
481492}
482493
483494module . exports = ScmRouter ;
Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ describe('index test', () => {
7575 mock . getReadOnlyInfo = sinon . stub ( ) . returns ( plugin ) ;
7676 mock . autoDeployKeyGenerationEnabled = sinon . stub ( ) . returns ( plugin ) ;
7777 mock . getWebhookEventsMapping = sinon . stub ( ) . returns ( { pr : 'pull_request' } ) ;
78+ mock . isEnterpriseUser = sinon . stub ( ) . returns ( true ) ;
7879
7980 return mock ;
8081 } ;
@@ -964,4 +965,17 @@ describe('index test', () => {
964965 assert . calledWith ( exampleScm . openPr , config ) ;
965966 } ) ) ;
966967 } ) ;
968+
969+ describe ( '_isEnterpriseUser' , ( ) => {
970+ const config = { scmContext : exampleScmContext } ;
971+
972+ it ( 'call origin _isEnterpriseUser' , ( ) =>
973+ scm . _isEnterpriseUser ( config ) . then ( result => {
974+ assert . strictEqual ( result , true ) ;
975+ assert . notCalled ( scmGithub . isEnterpriseUser ) ;
976+ assert . notCalled ( scmGitlab . isEnterpriseUser ) ;
977+ assert . calledOnce ( exampleScm . isEnterpriseUser ) ;
978+ assert . calledWith ( exampleScm . isEnterpriseUser , config ) ;
979+ } ) ) ;
980+ } ) ;
967981} ) ;
You can’t perform that action at this time.
0 commit comments