diff options
Diffstat (limited to 'spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb')
-rw-r--r-- | spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb | 39 |
1 files changed, 39 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..9c0be249a50 --- /dev/null +++ b/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb @@ -0,0 +1,39 @@ +require 'spec_helper' + +describe 'projects/notes/_more_actions_dropdown' do + let(:author_user) { create(:user) } + let(:not_author_user) { create(:user) } + + let(:project) { create(: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 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_link('Delete comment') + end + + it 'shows Delete button 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_link('Delete comment') + end +end |