Permalink
Browse files

fix(): fix hasPermission issue

  • Loading branch information...
jkuri committed Aug 21, 2017
1 parent f5b10fc commit b3c00149659c390e47211975e3000881b8f4d1d5
Showing with 16 additions and 24 deletions.
  1. +5 −5 e2e/050_builds.e2e.ts
  2. +1 −1 package-lock.json
  3. +10 −18 src/api/db/build.ts
@@ -141,16 +141,16 @@ describe('Builds', () => {
.then((): any => browser.wait(() => {
return element.all(by.css('.disabled')).count().then(cnt => cnt === 0);
}))
.then((): any => browser.wait(() => {
return element.all(by.css('.stop-build')).first().isPresent();
}))
.then((): any => {
return browser.wait(() => {
const el = element(by.css('.list-item:nth-child(1) .stop-build'));
const el = element(by.css('.stop-build'));
return ExpectedConditions.elementToBeClickable(el);
});
})
.then((): any => browser.wait(() => {
return element.all(by.css('.list-item:nth-child(1) .stop-build')).first().isPresent();
}))
.then((): any => element.all(by.css('.list-item:nth-child(1) .stop-build')).first().click())
.then((): any => element.all(by.css('.stop-build')).first().click())
.then((): any => browser.wait(() => {
return element.all(by.css('.is-running')).count().then(count => count === 0);
}));

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -35,12 +35,9 @@ export function getBuilds(limit: number, offset: number, userId?: number): Promi

return job;
});
build.hasPermission = false;
if (build.repository
&& build.repository.permissions
&& build.repository.permissions[0].permission) {
build.hasPermission = true;
}

build.hasPermission = build.repository.permissions &&
build.repository.permissions[0].permission;

return build;
});
@@ -100,12 +97,9 @@ export function getBuild(id: number, userId?: number): Promise<any> {
} else {
build.repository.access_token = null;
}
build.hasPermission = false;
if (build.repository
&& build.repository.permissions
&& build.repository.permissions[0].permission) {
build.hasPermission = true;
}

build.hasPermission = build.repository.permissions &&
build.repository.permissions[0].permission;

return build;
})
@@ -158,12 +152,9 @@ export function getLastBuild(userId?: number): Promise<any> {

return job;
});
build.hasPermission = false;
if (build.repository
&& build.repository.permissions
&& build.repository.permissions[0].permission) {
build.hasPermission = true;
}

build.hasPermission = build.repository.permissions &&
build.repository.permissions[0].permission;

resolve(build);
});
@@ -202,6 +193,7 @@ export function updateBuild(data: any): Promise<boolean> {
delete data.repository;
delete data.lastBuild;
delete data.runs;
delete data.hasPermission;

new Build({ id: data.id }).save(data, { method: 'update', require: false }).then(build => {
if (!build) {

0 comments on commit b3c0014

Please sign in to comment.