summaryrefslogtreecommitdiff
path: root/spec/views
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-06-14 17:12:22 +0100
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-06-16 09:14:21 +0100
commit2ef19a24a6dcba2bc3b3d5d66658d27b4ef10e43 (patch)
tree74397ba34be74517d91a17454c8c50e730fa93b6 /spec/views
parent20dcf5f83f9ac2583a2d2607fb8c8761906ec268 (diff)
downloadgitlab-ce-2ef19a24a6dcba2bc3b3d5d66658d27b4ef10e43.tar.gz
Add view spec for more_actions_dropdown render branches
Diffstat (limited to 'spec/views')
-rw-r--r--spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb70
1 files changed, 70 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..7a17cf58231
--- /dev/null
+++ b/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb
@@ -0,0 +1,70 @@
+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
+ allow(view).to receive(:note).and_return(note)
+ assign(:project, project)
+ end
+
+ context 'not editable and not current users comment' do
+ before do
+ allow(view).to receive(:note_editable).and_return(false)
+ allow(view).to receive(:current_user).and_return(not_author_user)
+
+ render
+ end
+
+ it 'shows Report as abuse button' do
+ expect(rendered).to have_link('Report as abuse')
+ end
+ end
+
+ context 'not editable and current users comment' do
+ before do
+ allow(view).to receive(:note_editable).and_return(false)
+ allow(view).to receive(:current_user).and_return(author_user)
+
+ render
+ end
+
+ it 'does not show the More actions button' do
+ expect(rendered).not_to have_selector('.dropdown.more-actions')
+ end
+ end
+
+ context 'editable and not current users comment' do
+ before do
+ allow(view).to receive(:note_editable).and_return(true)
+ allow(view).to receive(:current_user).and_return(not_author_user)
+
+ render
+ end
+
+ it 'shows Report as abuse, Edit and Delete buttons' do
+ expect(rendered).to have_link('Report as abuse')
+ expect(rendered).to have_button('Edit comment')
+ expect(rendered).to have_link('Delete comment')
+ end
+ end
+
+ context 'editable and current users comment' do
+ before do
+ allow(view).to receive(:note_editable).and_return(true)
+ allow(view).to receive(:current_user).and_return(author_user)
+
+ render
+ end
+
+ it 'shows Edit and Delete buttons' do
+ expect(rendered).to have_button('Edit comment')
+ expect(rendered).to have_link('Delete comment')
+ end
+ end
+end