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 | 63 | it("should create an article in a profile", (done) => { |
64 | 64 | let profileId = 1; |
65 | 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 | 67 | articleService.createInProfile(<noosfero.Profile>{id: profileId}, article).then((result: noosfero.RestResult<noosfero.Article>) => { |
68 | 68 | expect(result.data).toEqual({ id: 2 }); |
69 | 69 | done(); | ... | ... |
src/lib/ng-noosfero-api/http/article.service.ts
... | ... | @@ -26,7 +26,8 @@ export class ArticleService extends RestangularService<noosfero.Article> { |
26 | 26 | createInProfile(profile: noosfero.Profile, article: noosfero.Article): ng.IPromise<noosfero.RestResult<noosfero.Article>> { |
27 | 27 | let profileElement = this.profileService.get(<number>profile.id); |
28 | 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 | 111 | |
112 | 112 | let restRequest: ng.IPromise<any>; |
113 | 113 | |
114 | - debugger; | |
115 | - | |
116 | - | |
117 | 114 | if (rootElement) { |
118 | 115 | restRequest = rootElement.customGET(this.getResourcePath(), queryParams, headers); |
119 | 116 | } else { |
... | ... | @@ -133,7 +130,8 @@ export abstract class RestangularService<T extends noosfero.RestModel> { |
133 | 130 | let deferred = this.$q.defer<noosfero.RestResult<C>>(); |
134 | 131 | let restRequest: ng.IPromise<noosfero.RestResult<T>>; |
135 | 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 | 135 | restRequest.then(this.getHandleSuccessFunction(deferred)) |
138 | 136 | .catch(this.getHandleErrorFunction(deferred)); |
139 | 137 | return deferred.promise; | ... | ... |