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

show.html.haml_spec.rb « merge_requests « projects « views « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6b6bc1f0b144f03838d42c1c2e553c7542cd169c (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
71
72
73
74
75
76
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'projects/merge_requests/show.html.haml', :aggregate_failures do
  using RSpec::Parameterized::TableSyntax

  include_context 'merge request show action'

  before do
    merge_request.reload
  end

  context 'when the merge request is open' do
    it 'shows the "Mark as draft" button' do
      render

      expect(rendered).to have_css('a', visible: true, text: 'Mark as draft')
      expect(rendered).to have_css('a', visible: false, text: 'Reopen')
      expect(rendered).to have_css('a', visible: true, text: 'Close')
    end
  end

  context 'when the merge request is closed' do
    before do
      merge_request.close!
    end

    it 'shows the "Reopen" button' do
      render

      expect(rendered).not_to have_css('a', visible: true, text: 'Mark as draft')
      expect(rendered).to have_css('a', visible: true, text: 'Reopen')
      expect(rendered).to have_css('a', visible: false, text: 'Close')
    end

    context 'when source project does not exist' do
      it 'does not show the "Reopen" button' do
        allow(merge_request).to receive(:source_project).and_return(nil)

        render

        expect(rendered).to have_css('a', visible: false, text: 'Reopen')
        expect(rendered).to have_css('a', visible: false, text: 'Close')
      end
    end
  end

  describe 'gitpod modal' do
    let(:gitpod_modal_selector) { '#modal-enable-gitpod' }
    let(:user) { create(:user) }
    let(:user_gitpod_enabled) { create(:user).tap { |x| x.update!(gitpod_enabled: true) } }

    where(:site_enabled, :current_user, :should_show) do
      false | ref(:user) | false
      true  | ref(:user) | true
      true  | nil | true
      true  | ref(:user_gitpod_enabled) | false
    end

    with_them do
      it 'handles rendering gitpod user enable modal' do
        allow(Gitlab::CurrentSettings).to receive(:gitpod_enabled).and_return(site_enabled)
        allow(view).to receive(:current_user).and_return(current_user)

        render

        if should_show
          expect(rendered).to have_css(gitpod_modal_selector)
        else
          expect(rendered).to have_no_css(gitpod_modal_selector)
        end
      end
    end
  end
end