BigW Consortium Gitlab

_more_actions_dropdown.html.haml_spec.rb 1.46 KB
Newer Older
1 2
require 'spec_helper'

3
describe 'projects/notes/_more_actions_dropdown' do
4 5 6
  let(:author_user) { create(:user) }
  let(:not_author_user) { create(:user) }

7
  let(:project) { create(:project) }
8 9 10 11 12 13 14
  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

15 16
  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
17

18
    expect(rendered).to have_link('Report as abuse')
19 20
  end

21 22
  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
23

24
    expect(rendered).not_to have_selector('.dropdown.more-actions')
25 26
  end

27
  it 'shows Report as abuse and Delete buttons if editable and not current users comment' do
28
    render 'projects/notes/more_actions_dropdown', current_user: not_author_user, note_editable: true, note: note
29

30 31
    expect(rendered).to have_link('Report as abuse')
    expect(rendered).to have_link('Delete comment')
32 33
  end

34
  it 'shows Delete button if editable and current users comment' do
35
    render 'projects/notes/more_actions_dropdown', current_user: author_user, note_editable: true, note: note
36

37
    expect(rendered).to have_link('Delete comment')
38 39
  end
end