diff --git a/src/app/article/article-default-view-component.spec.ts b/src/app/article/article-default-view-component.spec.ts index 3cb7d19..44cc87e 100644 --- a/src/app/article/article-default-view-component.spec.ts +++ b/src/app/article/article-default-view-component.spec.ts @@ -1,6 +1,7 @@ import {Input, provide, Component} from 'ng-forward'; import {ArticleViewComponent, ArticleDefaultViewComponent} from './article-default-view.component'; import {ComponentTestHelper, createClass} from './../../spec/component-test-helper'; +import {PermissionDirective} from '../shared/components/permission/permission.directive'; import * as helpers from "../../spec/helpers"; @@ -45,7 +46,7 @@ describe("Components", () => { // in each test if one needs customization of these parameters per test let cls = createClass({ template: defaultViewTemplate, - directives: [ArticleDefaultViewComponent], + directives: [ArticleDefaultViewComponent, PermissionDirective], providers: providers, properties: { article: article @@ -65,16 +66,24 @@ describe("Components", () => { expect(state.transitionTo).toHaveBeenCalled(); }); + it("hide delete article button when user doesn't have permission", () => { + expect(helper.find(".article-toolbar .delete-article").attr('style')).toEqual("display: none; "); + }); + + it("hide edit article button when user doesn't have permission", () => { + expect(helper.find(".article-toolbar .edit-article").attr('style')).toEqual("display: none; "); + }); + /** * Execute the delete method on the target component */ function doDeleteArticle() { // Create a mock for the notification service confirmation - spyOn(helper.component.notificationService, 'confirmation').and.callFake(function (params: Function) { + spyOn(helper.component.notificationService, 'confirmation').and.callFake(function(params: Function) { }); // Create a mock for the ArticleService removeArticle method - spyOn(helper.component.articleService, 'remove').and.callFake(function (param: noosfero.Article) { + spyOn(helper.component.articleService, 'remove').and.callFake(function(param: noosfero.Article) { return { catch: () => { } diff --git a/src/app/article/article.html b/src/app/article/article.html index 123a264..876ad3c 100644 --- a/src/app/article/article.html +++ b/src/app/article/article.html @@ -4,13 +4,15 @@
- - {{"article.actions.edit" | translate}} - - - {{"article.actions.delete" | translate}} - - +
+ + {{"article.actions.edit" | translate}} + + + {{"article.actions.delete" | translate}} + + +
diff --git a/src/app/article/content-viewer/navbar-actions.html b/src/app/article/content-viewer/navbar-actions.html index fac7f40..72f9c01 100644 --- a/src/app/article/content-viewer/navbar-actions.html +++ b/src/app/article/content-viewer/navbar-actions.html @@ -1,4 +1,4 @@ -