Commit e5783cb34f5b631e379eeb6c83a1df3ae7793b3e
1 parent
bdd92ab9
Exists in
master
and in
31 other branches
fixed tests of articleService
Showing
3 changed files
with
5 additions
and
6 deletions
Show diff stats
src/lib/ng-noosfero-api/http/article.service.spec.ts
@@ -63,7 +63,7 @@ describe("Services", () => { | @@ -63,7 +63,7 @@ describe("Services", () => { | ||
63 | it("should create an article in a profile", (done) => { | 63 | it("should create an article in a profile", (done) => { |
64 | let profileId = 1; | 64 | let profileId = 1; |
65 | let article: noosfero.Article = <any>{ id: null}; | 65 | let article: noosfero.Article = <any>{ id: null}; |
66 | - $httpBackend.expectPOST(`/api/v1/profiles/${profileId}/articles`, { article: article }).respond(200, {article: { id: 2 }}); | 66 | + $httpBackend.expectPOST(`/api/v1/profiles/${profileId}/articles`, article).respond(200, {article: { id: 2 }}); |
67 | articleService.createInProfile(<noosfero.Profile>{id: profileId}, article).then((result: noosfero.RestResult<noosfero.Article>) => { | 67 | articleService.createInProfile(<noosfero.Profile>{id: profileId}, article).then((result: noosfero.RestResult<noosfero.Article>) => { |
68 | expect(result.data).toEqual({ id: 2 }); | 68 | expect(result.data).toEqual({ id: 2 }); |
69 | done(); | 69 | done(); |
src/lib/ng-noosfero-api/http/article.service.ts
@@ -26,7 +26,8 @@ export class ArticleService extends RestangularService<noosfero.Article> { | @@ -26,7 +26,8 @@ export class ArticleService extends RestangularService<noosfero.Article> { | ||
26 | createInProfile(profile: noosfero.Profile, article: noosfero.Article): ng.IPromise<noosfero.RestResult<noosfero.Article>> { | 26 | createInProfile(profile: noosfero.Profile, article: noosfero.Article): ng.IPromise<noosfero.RestResult<noosfero.Article>> { |
27 | let profileElement = this.profileService.get(<number>profile.id); | 27 | let profileElement = this.profileService.get(<number>profile.id); |
28 | (<any>profileElement).id = profile.id; | 28 | (<any>profileElement).id = profile.id; |
29 | - return this.create(article, profile); | 29 | + debugger; |
30 | + return this.create(article, <noosfero.RestModel>profileElement); | ||
30 | } | 31 | } |
31 | 32 | ||
32 | 33 |
src/lib/ng-noosfero-api/http/restangular_service.ts
@@ -111,9 +111,6 @@ export abstract class RestangularService<T extends noosfero.RestModel> { | @@ -111,9 +111,6 @@ export abstract class RestangularService<T extends noosfero.RestModel> { | ||
111 | 111 | ||
112 | let restRequest: ng.IPromise<any>; | 112 | let restRequest: ng.IPromise<any>; |
113 | 113 | ||
114 | - debugger; | ||
115 | - | ||
116 | - | ||
117 | if (rootElement) { | 114 | if (rootElement) { |
118 | restRequest = rootElement.customGET(this.getResourcePath(), queryParams, headers); | 115 | restRequest = rootElement.customGET(this.getResourcePath(), queryParams, headers); |
119 | } else { | 116 | } else { |
@@ -133,7 +130,8 @@ export abstract class RestangularService<T extends noosfero.RestModel> { | @@ -133,7 +130,8 @@ export abstract class RestangularService<T extends noosfero.RestModel> { | ||
133 | let deferred = this.$q.defer<noosfero.RestResult<C>>(); | 130 | let deferred = this.$q.defer<noosfero.RestResult<C>>(); |
134 | let restRequest: ng.IPromise<noosfero.RestResult<T>>; | 131 | let restRequest: ng.IPromise<noosfero.RestResult<T>>; |
135 | let objElement = this.getElement(obj.id); | 132 | let objElement = this.getElement(obj.id); |
136 | - restRequest = objElement.all(subElement).get(queryParams, headers); | 133 | + objElement.id = obj.id; |
134 | + restRequest = objElement.customGET(subElement, queryParams, headers); | ||
137 | restRequest.then(this.getHandleSuccessFunction(deferred)) | 135 | restRequest.then(this.getHandleSuccessFunction(deferred)) |
138 | .catch(this.getHandleErrorFunction(deferred)); | 136 | .catch(this.getHandleErrorFunction(deferred)); |
139 | return deferred.promise; | 137 | return deferred.promise; |