From f08d5868a840cba0c1bc3cec534ed26417650c01 Mon Sep 17 00:00:00 2001 From: Izak Lipnik Date: Thu, 12 Oct 2017 14:30:17 +0200 Subject: [PATCH] fix(): show private repositories on permissions tab --- src/api/db/repository.ts | 2 - .../app-repositories.component.spec.ts | 4 +- .../app-repository.component.html | 4 +- .../app-user/app-user.component.spec.ts | 12 +++++- .../components/app-user/app-user.component.ts | 2 +- src/app/testing/xhr-data/repositories.json | 37 +++++++++++++++++++ 6 files changed, 53 insertions(+), 8 deletions(-) diff --git a/src/api/db/repository.ts b/src/api/db/repository.ts index 18f7a4c73..b560ec219 100644 --- a/src/api/db/repository.ts +++ b/src/api/db/repository.ts @@ -152,8 +152,6 @@ export function getRepositories(keyword: string, userId?: string): Promise { if (userId) { diff --git a/src/app/components/app-repositories/app-repositories.component.spec.ts b/src/app/components/app-repositories/app-repositories.component.spec.ts index 84b89aad4..047d7832f 100644 --- a/src/app/components/app-repositories/app-repositories.component.spec.ts +++ b/src/app/components/app-repositories/app-repositories.component.spec.ts @@ -81,9 +81,9 @@ describe('Repositories Component', () => { expect(de.nativeElement.textContent).toContain('Repositories'); }); - it('should see two repositories', () => { + it('should see three repositories', () => { fixture.detectChanges(); - expect(fixture.componentInstance.repositories.length).toBe(2); + expect(fixture.componentInstance.repositories.length).toBe(3); }); it('first repository should be bterm', () => { diff --git a/src/app/components/app-repository/app-repository.component.html b/src/app/components/app-repository/app-repository.component.html index f461d1cf1..9c9b5c962 100644 --- a/src/app/components/app-repository/app-repository.component.html +++ b/src/app/components/app-repository/app-repository.component.html @@ -45,11 +45,11 @@

{{ repo?.full_name }}

{{ repo?.default_branch }} - + Private Repository - + Public Repository diff --git a/src/app/components/app-user/app-user.component.spec.ts b/src/app/components/app-user/app-user.component.spec.ts index c4f033ffc..dbae8b6c4 100644 --- a/src/app/components/app-user/app-user.component.spec.ts +++ b/src/app/components/app-user/app-user.component.spec.ts @@ -99,7 +99,7 @@ describe('User Component', () => { it('should get Repositories', () => { return apiService.getRepositories('', '1').toPromise().then(repositories => { if (repositories) { - expect(repositories.length).toEqual(2); + expect(repositories.length).toEqual(3); } else { Promise.reject(false); } @@ -132,6 +132,16 @@ describe('User Component', () => { const de = fixture.debugElement.query(By.css('h1')); expect(de.nativeElement.textContent).toBe('Permissions'); }); + + it('should show repositories on permission tab', () => { + fixture.detectChanges(); + fixture.debugElement.query(By.css('[name="tab-permissions"]')).nativeElement.click(); + fixture.detectChanges(); + const de = fixture.debugElement.query(By.css('h1')); + expect(de.nativeElement.textContent).toBe('Permissions'); + expect(fixture.componentInstance.restrictedRepositories.length).toBe(1); + expect(fixture.componentInstance.repositories.length).toBe(2); + }); }); }); diff --git a/src/app/components/app-user/app-user.component.ts b/src/app/components/app-user/app-user.component.ts index 34aa215e2..51f5bbb5e 100644 --- a/src/app/components/app-user/app-user.component.ts +++ b/src/app/components/app-user/app-user.component.ts @@ -70,7 +70,7 @@ export class AppUserComponent implements OnInit { }); this.route.params - .switchMap((params: Params) => this.api.getRepositories('', params.id)) + .switchMap((params: Params) => this.api.getRepositories('')) .subscribe(repositories => { this.repositories = repositories.filter(r => r.permissions.findIndex(p => p.permission) !== -1); diff --git a/src/app/testing/xhr-data/repositories.json b/src/app/testing/xhr-data/repositories.json index 21c37c3af..9e6be300e 100644 --- a/src/app/testing/xhr-data/repositories.json +++ b/src/app/testing/xhr-data/repositories.json @@ -73,6 +73,43 @@ "updated_at": 1507286468433 } ] + }, + { + "id": 3, + "github_id": 71424198, + "bitbucket_id": null, + "gitlab_id": null, + "gogs_id": null, + "clone_url": "https://github.com/jkuri/d3-bundle.git", + "html_url": "https://github.com/jkuri/d3-bundle", + "default_branch": "master", + "name": "d3-bundle", + "full_name": "jkuri/d3-bundle", + "description": null, + "api_url": "https://api.github.com", + "repository_provider": "github", + "private": 1, + "fork": 0, + "user_login": "jkuri", + "user_id": "1796022", + "user_avatar_url": "https://avatars1.githubusercontent.com/u/1796022?v=4", + "user_url": "https://api.github.com/users/jkuri", + "user_html_url": "https://github.com/jkuri", + "access_tokens_id": null, + "public": 0, + "data": null, + "created_at": 1507286468355, + "updated_at": 1507286468355, + "permissions": [ + { + "id": 3, + "repositories_id": 3, + "users_id": 1, + "permission": 0, + "created_at": 1507286468433, + "updated_at": 1507286468433 + } + ] } ] }