Skip to content

Commit

Permalink
Adding missing update to new article's authorId field.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Sik committed Sep 17, 2015
1 parent ffb8ebf commit 9811311
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/src/app/admin/articles/article/article.spec.ts
Expand Up @@ -115,6 +115,8 @@ namespace app.admin.articles.article {

expect(article._author).to.deep.equal(loggedInUser);

expect(article.authorId).to.equal(loggedInUser.userId);

});

it('should be able to resolve article (existing)', () => {
Expand Down
5 changes: 4 additions & 1 deletion app/src/app/admin/articles/article/article.ts
Expand Up @@ -61,8 +61,11 @@ namespace app.admin.articles.article {
article: (articleService:common.services.article.ArticleService, $stateParams:IArticleStateParams, userService:common.services.user.UserService):common.models.Article | ng.IPromise<common.models.Article> => {

if (!$stateParams.permalink || $stateParams.permalink == 'new'){
let currentUser = userService.getAuthUser();

let newArticle = articleService.newArticle();
newArticle._author = userService.getAuthUser();
newArticle._author = currentUser;
newArticle.authorId = currentUser.userId;
$stateParams.permalink = 'new';
$stateParams.newArticle = true;
return newArticle;
Expand Down

0 comments on commit 9811311

Please sign in to comment.