Skip to content

Commit

Permalink
fix(): show private repositories on permissions tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Izak88 committed Oct 12, 2017
1 parent d865532 commit f08d586
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/api/db/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ export function getRepositories(keyword: string, userId?: string): Promise<any[]
.andWhere(function() {
this.where('permissions.permission', true).orWhere('public', true);
});
} else {
q.where('repositories.public', true);
}
}).fetchAll({ withRelated: [{'permissions': (query) => {
if (userId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ <h1 class="mr15 repository-h1">{{ repo?.full_name }}</h1>
{{ repo?.default_branch }}
</span>
<span *ngIf="repo?.private">
<i class="ion ion-ios-unlocked-outline"></i>
<i class="ion ion-ios-locked-outline"></i>
Private Repository
</span>
<span *ngIf="!repo?.private">
<i class="ion ion-ios-locked-outline"></i>
<i class="ion ion-ios-unlocked-outline"></i>
Public Repository
</span>
</div>
Expand Down
12 changes: 11 additions & 1 deletion src/app/components/app-user/app-user.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
});
});

});
2 changes: 1 addition & 1 deletion src/app/components/app-user/app-user.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
37 changes: 37 additions & 0 deletions src/app/testing/xhr-data/repositories.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}
]
}

0 comments on commit f08d586

Please sign in to comment.