diff --git a/src/app/cms/cms.component.spec.ts b/src/app/cms/cms.component.spec.ts index 07b179d..f4fbf01 100644 --- a/src/app/cms/cms.component.spec.ts +++ b/src/app/cms/cms.component.spec.ts @@ -22,7 +22,7 @@ describe("Components", () => { $state = jasmine.createSpyObj("$state", ["transitionTo"]); notification = jasmine.createSpyObj("notification", ["success"]); profileServiceMock = jasmine.createSpyObj("profileServiceMock", ["getCurrentProfile"]); - articleServiceMock = jasmine.createSpyObj("articleServiceMock", ["create"]); + articleServiceMock = jasmine.createSpyObj("articleServiceMock", ["createInProfile"]); let getCurrentProfileResponse = $q.defer(); getCurrentProfileResponse.resolve(profile); @@ -31,7 +31,7 @@ describe("Components", () => { articleCreate.resolve({ data: { path: "path", profile: { identifier: "profile" } }}); profileServiceMock.getCurrentProfile = jasmine.createSpy("getCurrentProfile").and.returnValue(getCurrentProfileResponse.promise); - articleServiceMock.create = jasmine.createSpy("create").and.returnValue(articleCreate.promise); + articleServiceMock.createInProfile = jasmine.createSpy("createInProfile").and.returnValue(articleCreate.promise); }); it("create an article in the current profile when save", done => { @@ -39,7 +39,7 @@ describe("Components", () => { component.save(); $rootScope.$apply(); expect(profileServiceMock.getCurrentProfile).toHaveBeenCalled(); - expect(articleServiceMock.create).toHaveBeenCalledWith(component.article, profile); + expect(articleServiceMock.createInProfile).toHaveBeenCalledWith(profile, component.article); done(); }); diff --git a/src/app/cms/cms.component.ts b/src/app/cms/cms.component.ts index a66289c..2ce909f 100644 --- a/src/app/cms/cms.component.ts +++ b/src/app/cms/cms.component.ts @@ -24,7 +24,7 @@ export class Cms { save() { this.profileService.getCurrentProfile().then((profile: noosfero.Profile) => { - return this.articleService.create(this.article, profile); + return this.articleService.createInProfile(profile, this.article); }).then((response: noosfero.RestResult) => { let article = (response.data); this.$state.transitionTo('main.profile.page', { page: article.path, profile: article.profile.identifier }); diff --git a/src/lib/ng-noosfero-api/http/article.service.ts b/src/lib/ng-noosfero-api/http/article.service.ts index 63385fe..1476152 100644 --- a/src/lib/ng-noosfero-api/http/article.service.ts +++ b/src/lib/ng-noosfero-api/http/article.service.ts @@ -26,8 +26,10 @@ 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; - debugger; - return this.create(article, profileElement); + let headers = { + 'Content-Type': 'application/json' + } + return this.create(article, profileElement, null, headers); } -- libgit2 0.21.2