summaryrefslogtreecommitdiff
path: root/spec/features/groups/empty_states_spec.rb
blob: fef8e41bffe1692dbae4ce6e73670016941c2493 (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'

feature 'Groups Merge Requests Empty States' do
  let(:group) { create(:group) }
  let(:user) { create(:group_member, :developer, user: create(:user), group: group ).user }

  before do
    login_as(user)
  end

  context 'group has a project' do
    let(:project) { create(:empty_project, namespace: group) }

    before do
      project.add_master(user)
    end

    context 'the project has a merge request' do
      before do
        create(:merge_request, source_project: project)

        visit merge_requests_group_path(group)
      end

      it 'should not display an empty state' do
        expect(page).not_to have_selector('.empty-state')
      end
    end

    context 'the project has no merge requests', :js do
      before do
        visit merge_requests_group_path(group)
      end

      it 'should display an empty state' do
        expect(page).to have_selector('.empty-state')
      end

      it 'should show a new merge request button' do
        within '.empty-state' do
          expect(page).to have_content('New merge request')
        end
      end

      it 'the new merge request button opens a project dropdown' do
        within '.empty-state' do
          find('.new-project-item-select-button').click
        end

        expect(page).to have_selector('.ajax-project-dropdown')
      end
    end
  end

  context 'group without a project' do
    before do
      visit merge_requests_group_path(group)
    end

    it 'should display an empty state' do
      expect(page).to have_selector('.empty-state')
    end

    it 'should not show a new merge request button' do
      within '.empty-state' do
        expect(page).not_to have_link('New merge request')
      end
    end
  end
end