Skip to content

Commit a19603f

Browse files
authored
feat(1319): Add getOrgPermissions (#12)
1 parent 517f735 commit a19603f

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,17 @@ class ScmRouter extends Scm {
235235
return this.chooseScm(config).then(scm => scm.getPermissions(config));
236236
}
237237

238+
/**
239+
* Get a users permissions on an organization
240+
* @method getOrgPermissions
241+
* @param {Object} config Configuration
242+
* @param {String} config.scmContext Name of scm context
243+
* @return {Promise}
244+
*/
245+
_getOrgPermissions(config) {
246+
return this.chooseScm(config).then(scm => scm.getOrgPermissions(config));
247+
}
248+
238249
/**
239250
* Get a commit sha for a specific repo#branch or pull request
240251
* @method _getCommitSha

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@
3535
"devDependencies": {
3636
"chai": "^3.5.0",
3737
"eslint": "^4.19.1",
38-
"eslint-config-screwdriver": "^3.0.0",
39-
"hoek": "^5.0.3",
40-
"jenkins-mocha": "^4.0.0",
38+
"eslint-config-screwdriver": "^3.0.1",
39+
"hoek": "^5.0.4",
40+
"jenkins-mocha": "^6.0.0",
4141
"mockery": "^2.0.0",
4242
"sinon": "^2.3.4"
4343
},
4444
"dependencies": {
45-
"async": "^2.0.1",
46-
"screwdriver-scm-base": "^4.0.1"
45+
"async": "^2.6.1",
46+
"screwdriver-scm-base": "^4.4.3"
4747
},
4848
"release": {
4949
"debug": false,

test/index.test.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ describe('index test', () => {
4444
'decorateCommit',
4545
'decorateAuthor',
4646
'getPermissions',
47+
'getOrgPermissions',
4748
'getCommitSha',
4849
'updateCommitStatus',
4950
'getFile',
@@ -675,7 +676,7 @@ describe('index test', () => {
675676
describe('_getPermissions', () => {
676677
const config = { scmContext: 'example.context' };
677678

678-
it('call origin getPermissons', () => {
679+
it('call origin getPermissions', () => {
679680
const scmGithub = scm.scms['github.context'];
680681
const exampleScm = scm.scms['example.context'];
681682
const scmGitlab = scm.scms['gitlab.context'];
@@ -691,6 +692,25 @@ describe('index test', () => {
691692
});
692693
});
693694

695+
describe('_getOrgPermissions', () => {
696+
const config = { scmContext: 'example.context' };
697+
698+
it('call origin getOrgPermissions', () => {
699+
const scmGithub = scm.scms['github.context'];
700+
const exampleScm = scm.scms['example.context'];
701+
const scmGitlab = scm.scms['gitlab.context'];
702+
703+
return scm._getOrgPermissions(config)
704+
.then((result) => {
705+
assert.strictEqual(result, 'example');
706+
assert.notCalled(scmGithub.getOrgPermissions);
707+
assert.notCalled(scmGitlab.getOrgPermissions);
708+
assert.calledOnce(exampleScm.getOrgPermissions);
709+
assert.calledWith(exampleScm.getOrgPermissions, config);
710+
});
711+
});
712+
});
713+
694714
describe('_getCommitSha', () => {
695715
const config = { scmContext: 'example.context' };
696716

0 commit comments

Comments
 (0)