Skip to content

Commit

Permalink
feat(1319): Add getOrgPermissions (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkyi authored Nov 13, 2018
1 parent 517f735 commit a19603f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
11 changes: 11 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,17 @@ class ScmRouter extends Scm {
return this.chooseScm(config).then(scm => scm.getPermissions(config));
}

/**
* Get a users permissions on an organization
* @method getOrgPermissions
* @param {Object} config Configuration
* @param {String} config.scmContext Name of scm context
* @return {Promise}
*/
_getOrgPermissions(config) {
return this.chooseScm(config).then(scm => scm.getOrgPermissions(config));
}

/**
* Get a commit sha for a specific repo#branch or pull request
* @method _getCommitSha
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
"devDependencies": {
"chai": "^3.5.0",
"eslint": "^4.19.1",
"eslint-config-screwdriver": "^3.0.0",
"hoek": "^5.0.3",
"jenkins-mocha": "^4.0.0",
"eslint-config-screwdriver": "^3.0.1",
"hoek": "^5.0.4",
"jenkins-mocha": "^6.0.0",
"mockery": "^2.0.0",
"sinon": "^2.3.4"
},
"dependencies": {
"async": "^2.0.1",
"screwdriver-scm-base": "^4.0.1"
"async": "^2.6.1",
"screwdriver-scm-base": "^4.4.3"
},
"release": {
"debug": false,
Expand Down
22 changes: 21 additions & 1 deletion test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ describe('index test', () => {
'decorateCommit',
'decorateAuthor',
'getPermissions',
'getOrgPermissions',
'getCommitSha',
'updateCommitStatus',
'getFile',
Expand Down Expand Up @@ -675,7 +676,7 @@ describe('index test', () => {
describe('_getPermissions', () => {
const config = { scmContext: 'example.context' };

it('call origin getPermissons', () => {
it('call origin getPermissions', () => {
const scmGithub = scm.scms['github.context'];
const exampleScm = scm.scms['example.context'];
const scmGitlab = scm.scms['gitlab.context'];
Expand All @@ -691,6 +692,25 @@ describe('index test', () => {
});
});

describe('_getOrgPermissions', () => {
const config = { scmContext: 'example.context' };

it('call origin getOrgPermissions', () => {
const scmGithub = scm.scms['github.context'];
const exampleScm = scm.scms['example.context'];
const scmGitlab = scm.scms['gitlab.context'];

return scm._getOrgPermissions(config)
.then((result) => {
assert.strictEqual(result, 'example');
assert.notCalled(scmGithub.getOrgPermissions);
assert.notCalled(scmGitlab.getOrgPermissions);
assert.calledOnce(exampleScm.getOrgPermissions);
assert.calledWith(exampleScm.getOrgPermissions, config);
});
});
});

describe('_getCommitSha', () => {
const config = { scmContext: 'example.context' };

Expand Down

0 comments on commit a19603f

Please sign in to comment.