From e5783cb34f5b631e379eeb6c83a1df3ae7793b3e Mon Sep 17 00:00:00 2001 From: Abner Oliveira Date: Wed, 16 Mar 2016 14:49:55 -0300 Subject: [PATCH] fixed tests of articleService --- src/lib/ng-noosfero-api/http/article.service.spec.ts | 2 +- src/lib/ng-noosfero-api/http/article.service.ts | 3 ++- src/lib/ng-noosfero-api/http/restangular_service.ts | 6 ++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/lib/ng-noosfero-api/http/article.service.spec.ts b/src/lib/ng-noosfero-api/http/article.service.spec.ts index 1453489..41539e9 100644 --- a/src/lib/ng-noosfero-api/http/article.service.spec.ts +++ b/src/lib/ng-noosfero-api/http/article.service.spec.ts @@ -63,7 +63,7 @@ describe("Services", () => { it("should create an article in a profile", (done) => { let profileId = 1; let article: noosfero.Article = { id: null}; - $httpBackend.expectPOST(`/api/v1/profiles/${profileId}/articles`, { article: article }).respond(200, {article: { id: 2 }}); + $httpBackend.expectPOST(`/api/v1/profiles/${profileId}/articles`, article).respond(200, {article: { id: 2 }}); articleService.createInProfile({id: profileId}, article).then((result: noosfero.RestResult) => { expect(result.data).toEqual({ id: 2 }); done(); diff --git a/src/lib/ng-noosfero-api/http/article.service.ts b/src/lib/ng-noosfero-api/http/article.service.ts index 9e62124..47aecd2 100644 --- a/src/lib/ng-noosfero-api/http/article.service.ts +++ b/src/lib/ng-noosfero-api/http/article.service.ts @@ -26,7 +26,8 @@ export class ArticleService extends RestangularService { createInProfile(profile: noosfero.Profile, article: noosfero.Article): ng.IPromise> { let profileElement = this.profileService.get(profile.id); (profileElement).id = profile.id; - return this.create(article, profile); + debugger; + return this.create(article, profileElement); } diff --git a/src/lib/ng-noosfero-api/http/restangular_service.ts b/src/lib/ng-noosfero-api/http/restangular_service.ts index ef93aeb..900939c 100644 --- a/src/lib/ng-noosfero-api/http/restangular_service.ts +++ b/src/lib/ng-noosfero-api/http/restangular_service.ts @@ -111,9 +111,6 @@ export abstract class RestangularService { let restRequest: ng.IPromise; - debugger; - - if (rootElement) { restRequest = rootElement.customGET(this.getResourcePath(), queryParams, headers); } else { @@ -133,7 +130,8 @@ export abstract class RestangularService { let deferred = this.$q.defer>(); let restRequest: ng.IPromise>; let objElement = this.getElement(obj.id); - restRequest = objElement.all(subElement).get(queryParams, headers); + objElement.id = obj.id; + restRequest = objElement.customGET(subElement, queryParams, headers); restRequest.then(this.getHandleSuccessFunction(deferred)) .catch(this.getHandleErrorFunction(deferred)); return deferred.promise; -- libgit2 0.21.2