Welcome to mirror list, hosted at ThFree Co, Russian Federation.

_more_actions_dropdown.html.haml_spec.rb « notes « projects « views « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7a17cf58231815b8ea9cbc5e58c335f254454139 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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