fix check isSignificantPullRequest

This commit is contained in:
Anton Kharitonov 2019-06-26 14:03:11 +02:00
Родитель 6ce5e14726
Коммит 7e64038760
3 изменённых файлов: 18 добавлений и 14 удалений

Просмотреть файл

@ -96,4 +96,4 @@
"test": "node_modules/grunt/bin/grunt test",
"acceptance_test": "source .env && npx codeceptjs run"
}
}
}

Просмотреть файл

@ -249,10 +249,10 @@ class ClaService {
}
token = token || item.token // in case this method is called via controller/default.js check -> api/cla.js validatePullRequest -> services/cla.js isCLARequired there is no user token
const pullRequest = await this._getPR(owner, repo, number, token, true)
if (typeof item.minFileChanges === 'number' && pullRequest.changed_files >= item.minFileChanges) {
if (typeof item.minFileChanges === 'number' && pullRequest.data.changed_files >= item.minFileChanges) {
return true
}
if (typeof item.minCodeChanges === 'number' && pullRequest.additions + pullRequest.deletions >= item.minCodeChanges) {
if (typeof item.minCodeChanges === 'number' && pullRequest.data.additions + pullRequest.data.deletions >= item.minCodeChanges) {
return true
}

Просмотреть файл

@ -1585,9 +1585,7 @@ describe('cla:isClaRequired', () => {
it('should require a CLA when pull request exceed minimum file changes', async () => {
testRes.repoServiceGet.minFileChanges = 2
testRes.getPR = {
changed_files: 2,
}
testRes.getPR = { data: { changed_files: 2 } }
const claIsRequired = await cla.isClaRequired(args)
@ -1602,8 +1600,10 @@ describe('cla:isClaRequired', () => {
it('should require a CLA when pull request exceed minimum code changes', async () => {
testRes.repoServiceGet.minCodeChanges = 15
testRes.getPR = {
deletions: 10,
additions: 10,
data: {
deletions: 10,
additions: 10,
}
}
const claIsRequired = await cla.isClaRequired(args)
@ -1620,9 +1620,11 @@ describe('cla:isClaRequired', () => {
testRes.repoServiceGet.minFileChanges = 2
testRes.repoServiceGet.minCodeChanges = 15
testRes.getPR = {
changed_files: 1,
deletions: 7,
additions: 7
data: {
changed_files: 1,
deletions: 7,
additions: 7
}
}
const claIsRequired = await cla.isClaRequired(args)
@ -1643,9 +1645,11 @@ describe('cla:isClaRequired', () => {
delete args.token
testRes.repoServiceGet.minCodeChanges = 15
testRes.getPR = {
changed_files: 1,
additions: 14,
deletions: 1
data: {
changed_files: 1,
additions: 14,
deletions: 1
}
}
const claIsRequired = await cla.isClaRequired(args)