Commit 5f327c2733cbb6ca3199f631f8209c9b42de0ec5

Authored by Victor Costa
1 parent 74c79a64

Add method to return the profile home page

src/lib/ng-noosfero-api/http/profile.service.spec.ts
@@ -70,6 +70,16 @@ describe("Services", () => { @@ -70,6 +70,16 @@ describe("Services", () => {
70 $rootScope.$apply(); 70 $rootScope.$apply();
71 }); 71 });
72 72
  73 + it("should return the profile home page", (done) => {
  74 + let profileId = 1;
  75 + $httpBackend.expectGET(`/api/v1/profiles/${profileId}/home_page`).respond(200, { article: { path: "/something" } });
  76 + profileService.getHomePage(profileId).then((response: restangular.IResponse) => {
  77 + expect(response.data.article).toEqual({ path: "/something" });
  78 + done();
  79 + });
  80 + $httpBackend.flush();
  81 + });
  82 +
73 }); 83 });
74 84
75 85
src/lib/ng-noosfero-api/http/profile.service.ts
@@ -19,6 +19,10 @@ export class ProfileService { @@ -19,6 +19,10 @@ export class ProfileService {
19 this._currentProfilePromise.resolve(profile); 19 this._currentProfilePromise.resolve(profile);
20 } 20 }
21 21
  22 + getHomePage(profileId: number, params?: any) {
  23 + return this.get(profileId).customGET("home_page", params);
  24 + }
  25 +
22 getByIdentifier(identifier: string): restangular.IPromise<any> { 26 getByIdentifier(identifier: string): restangular.IPromise<any> {
23 return this.restangular.one('profiles').get({ identifier: identifier }); 27 return this.restangular.one('profiles').get({ identifier: identifier });
24 } 28 }