Commit d56bc4d47f5421ce9b3c6b4faa67dffdcd0fbc44
1 parent
6b394e0b
Exists in
master
and in
26 other branches
Do now show comment form when article doesn't accept comments
Showing
6 changed files
with
21 additions
and
4 deletions
Show diff stats
src/app/article/comment/comment.html
... | ... | @@ -18,7 +18,7 @@ |
18 | 18 | <div class="title">{{ctrl.comment.title}}</div> |
19 | 19 | <div class="body">{{ctrl.comment.body}}</div> |
20 | 20 | <div class="actions" ng-if="ctrl.displayActions"> |
21 | - <a href="#" (click)="ctrl.reply()" class="small text-muted"> | |
21 | + <a href="#" (click)="ctrl.reply()" class="small text-muted" ng-if="ctrl.article.accept_comments"> | |
22 | 22 | {{"comment.reply" | translate}} |
23 | 23 | </a> |
24 | 24 | </div> | ... | ... |
src/app/article/comment/post-comment/post-comment.component.spec.ts
... | ... | @@ -7,6 +7,8 @@ const htmlTemplate: string = '<noosfero-post-comment [article]="ctrl.article" [r |
7 | 7 | describe("Components", () => { |
8 | 8 | describe("Post Comment Component", () => { |
9 | 9 | |
10 | + let properties = { article: { id: 1, accept_comments: true } }; | |
11 | + | |
10 | 12 | beforeEach(angular.mock.module("templates")); |
11 | 13 | |
12 | 14 | let commentService = jasmine.createSpyObj("commentService", ["createInArticle"]); |
... | ... | @@ -19,7 +21,7 @@ describe("Components", () => { |
19 | 21 | |
20 | 22 | @Component({ selector: 'test-container-component', directives: [PostCommentComponent], template: htmlTemplate, providers: providers }) |
21 | 23 | class ContainerComponent { |
22 | - article = { id: 1 }; | |
24 | + article = properties['article']; | |
23 | 25 | comment = { id: 2 }; |
24 | 26 | } |
25 | 27 | |
... | ... | @@ -30,6 +32,14 @@ describe("Components", () => { |
30 | 32 | }); |
31 | 33 | }); |
32 | 34 | |
35 | + it("not render the post comment form when article doesn't accept comments", done => { | |
36 | + properties['article'].accept_comments = false; | |
37 | + helpers.createComponentFromClass(ContainerComponent).then(fixture => { | |
38 | + expect(fixture.debugElement.queryAll("form").length).toEqual(0); | |
39 | + done(); | |
40 | + }); | |
41 | + }); | |
42 | + | |
33 | 43 | it("emit an event when create comment", done => { |
34 | 44 | helpers.createComponentFromClass(ContainerComponent).then(fixture => { |
35 | 45 | let component: PostCommentComponent = fixture.debugElement.componentViewChildren[0].componentInstance; | ... | ... |
src/app/article/comment/post-comment/post-comment.html
src/app/article/comment/post-comment/post-comment.scss