diff options
author | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-06-16 15:57:03 +0300 |
---|---|---|
committer | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-06-16 15:57:03 +0300 |
commit | f50a8065313b9cdc414aff157fcbfbdbfccd5a70 (patch) | |
tree | 69b322ebaff02052748389f8586630fd16a245a8 /spec/support | |
parent | 0bfe78d71628af28d3d7d8f743afcf6ed2447a9a (diff) |
Fixed reportable_note_shared_example for the reportable_note/snippets_spec
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/features/reportable_note_shared_examples.rb | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/spec/support/features/reportable_note_shared_examples.rb b/spec/support/features/reportable_note_shared_examples.rb index 0d80c95e826..560935704f7 100644 --- a/spec/support/features/reportable_note_shared_examples.rb +++ b/spec/support/features/reportable_note_shared_examples.rb @@ -1,6 +1,6 @@ require 'spec_helper' -shared_examples 'reportable note' do +shared_examples 'reportable note' do |is_a_personal_snippet| include NotesHelper let(:comment) { find("##{ActionView::RecordIdentifier.dom_id(note)}") } @@ -11,26 +11,47 @@ shared_examples 'reportable note' do expect(comment).to have_selector(more_actions_selector) end - it 'dropdown has Edit, Report and Delete links' do - dropdown = comment.find(more_actions_selector) - - dropdown.click - dropdown.find('.dropdown-menu li', match: :first) - - expect(dropdown).to have_button('Edit comment') - expect(dropdown).to have_link('Report as abuse', href: abuse_report_path) - expect(dropdown).to have_link('Delete comment', href: note_url(note, project)) + if is_a_personal_snippet + it 'dropdown has Report link on other users comment' do + dropdown = comment.find(more_actions_selector) + open_dropdown(dropdown) + + expect(dropdown).to have_link('Report as abuse', href: abuse_report_path) + end + + it 'dropdown has Edit and Delete links on the owners comment' do + find('#notes-list .note', match: :first) + other_comment = all('#notes-list .note').last + + dropdown = other_comment.find(more_actions_selector) + open_dropdown(dropdown) + + expect(dropdown).to have_button('Edit comment') + expect(dropdown).to have_link('Delete comment', href: note_url(owners_note, project)) + end + else + it 'dropdown has Edit, Report and Delete links' do + dropdown = comment.find(more_actions_selector) + open_dropdown(dropdown) + + expect(dropdown).to have_button('Edit comment') + expect(dropdown).to have_link('Report as abuse', href: abuse_report_path) + expect(dropdown).to have_link('Delete comment', href: note_url(note, project)) + end end it 'Report button links to a report page' do dropdown = comment.find(more_actions_selector) - - dropdown.click - dropdown.find('.dropdown-menu li', match: :first) + open_dropdown(dropdown) dropdown.click_link('Report as abuse') expect(find('#user_name')['value']).to match(note.author.username) expect(find('#abuse_report_message')['value']).to match(noteable_note_url(note)) end + + def open_dropdown(dropdown) + dropdown.click + dropdown.find('.dropdown-menu li', match: :first) + end end |