diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-06-20 16:04:46 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-06-20 16:04:46 +0000 |
commit | d9d020b169eb2c3b57f52d423fb5e8c6e907dd9f (patch) | |
tree | 5c5194db631e7477921b400980da51ed63b476ee /spec/views | |
parent | 207a53ce9826bbe0ffbe0712b67564fbd10b7015 (diff) | |
parent | 1f9fb9e45738995ab8935d2e71ca7df73c3fe23c (diff) | |
download | gitlab-ce-d9d020b169eb2c3b57f52d423fb5e8c6e907dd9f.tar.gz |
Merge branch 'hide-edit-comment-and-report-as-abuse-conditionally' into 'master'
Only show 'Edit comment'/'Report as abuse' when user has perms/isnt current_user
See merge request !12096
Diffstat (limited to 'spec/views')
-rw-r--r-- | spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb b/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb new file mode 100644 index 00000000000..e56c0f6be03 --- /dev/null +++ b/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe 'projects/notes/_more_actions_dropdown', :view do + let(:author_user) { create(:user) } + let(:not_author_user) { create(:user) } + + let(:project) { create(:empty_project) } + let(:issue) { create(:issue, project: project) } + let!(:note) { create(:note_on_issue, author: author_user, noteable: issue, project: project) } + + before do + assign(:project, project) + end + + it 'shows Report as abuse button if not editable and not current users comment' do + render 'projects/notes/more_actions_dropdown', current_user: not_author_user, note_editable: false, note: note + + expect(rendered).to have_link('Report as abuse') + end + + it 'does not show the More actions button if not editable and current users comment' do + render 'projects/notes/more_actions_dropdown', current_user: author_user, note_editable: false, note: note + + expect(rendered).not_to have_selector('.dropdown.more-actions') + end + + it 'shows Report as abuse, Edit and Delete buttons if editable and not current users comment' do + render 'projects/notes/more_actions_dropdown', current_user: not_author_user, note_editable: true, note: note + + expect(rendered).to have_link('Report as abuse') + expect(rendered).to have_button('Edit comment') + expect(rendered).to have_link('Delete comment') + end + + it 'shows Edit and Delete buttons if editable and current users comment' do + render 'projects/notes/more_actions_dropdown', current_user: author_user, note_editable: true, note: note + + expect(rendered).to have_button('Edit comment') + expect(rendered).to have_link('Delete comment') + end +end |