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

_sidebar.html.haml_spec.rb « issuable « shared « views « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 43a723dbb2cd828ab3b526daa3c968e8f748bf75 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'shared/issuable/_sidebar.html.haml' do
  let_it_be(:user) { create(:user) }

  subject(:rendered) do
    render 'shared/issuable/sidebar', issuable_sidebar: IssueSerializer.new(current_user: user)
      .represent(issuable, serializer: 'sidebar'), assignees: []
  end

  context 'project in a group' do
    let_it_be(:group) { create(:group, :crm_enabled) }
    let_it_be(:project) { create(:project, group: group) }
    let_it_be(:issue) { create(:issue, project: project) }
    let_it_be(:incident) { create(:incident, project: project) }

    before do
      assign(:project, project)
    end

    context 'issuable that does not support escalations' do
      let(:issuable) { incident }

      it 'shows escalation policy dropdown' do
        expect(rendered).to have_css('[data-testid="escalation_status_container"]')
      end
    end

    context 'issuable that supports escalations' do
      let(:issuable) { issue }

      it 'does not show escalation policy dropdown' do
        expect(rendered).not_to have_css('[data-testid="escalation_status_container"]')
      end
    end

    context 'crm contacts widget' do
      let(:issuable) { issue }

      context 'without permission' do
        it 'is expected not to be shown' do
          create(:contact, group: group)

          expect(rendered).not_to have_css('#js-issue-crm-contacts')
        end
      end

      context 'without contacts' do
        it 'is expected not to be shown' do
          group.add_developer(user)

          expect(rendered).not_to have_css('#js-issue-crm-contacts')
        end
      end

      context 'with permission and contacts' do
        it 'is expected to be shown' do
          create(:contact, group: group)
          group.add_developer(user)

          expect(rendered).to have_css('#js-issue-crm-contacts')
        end
      end
    end
  end
end