BigW Consortium Gitlab

runners_spec.rb 3.79 KB
Newer Older
1 2
require 'spec_helper'

3 4
feature 'Runners' do
  given(:user) { create(:user) }
5

6
  background do
7
    sign_in(user)
8
  end
9

10 11
  context 'when a project has enabled shared_runners' do
    given(:project) { create(:project) }
12

Shinya Maeda committed
13 14 15 16
    background do
      project.add_master(user)
    end

17 18
    context 'when a specific runner is activated on the project' do
      given(:specific_runner) { create(:ci_runner, :specific) }
19

20 21 22
      background do
        project.runners << specific_runner
      end
23

24 25
      scenario 'user sees the specific runner' do
        visit runners_path(project)
26

27 28 29
        within '.activated-specific-runners' do
          expect(page).to have_content(specific_runner.display_name)
        end
30

31
        click_on specific_runner.short_sha
32

33
        expect(page).to have_content(specific_runner.platform)
34 35
      end

Shinya Maeda committed
36
      scenario 'user removes an activated specific runner if this is last project for that runners' do
37
        visit runners_path(project)
38

39 40 41
        within '.activated-specific-runners' do
          click_on 'Remove Runner'
        end
42

Shinya Maeda committed
43
        expect(page).not_to have_content(specific_runner.display_name)
44 45
      end

46 47
      context 'when a runner has a tag' do
        background do
Shinya Maeda committed
48
          specific_runner.update(tag_list: ['tag'])
49
        end
50

51 52
        scenario 'user edits runner not to run untagged jobs' do
          visit runners_path(project)
53

54 55 56
          within '.activated-specific-runners' do
            first('.edit-runner > a').click
          end
57

58
          expect(page.find_field('runner[run_untagged]')).to be_checked
59

60 61
          uncheck 'runner_run_untagged'
          click_button 'Save changes'
62

63 64 65
          expect(page).to have_content 'Can run untagged jobs No'
        end
      end
66

Shinya Maeda committed
67 68
      context 'when a shared runner is activated on the project' do
        given!(:shared_runner) { create(:ci_runner, :shared) }
69

Shinya Maeda committed
70
        scenario 'user sees CI/CD setting page' do
71
          visit runners_path(project)
72

Shinya Maeda committed
73 74 75 76
          expect(page.find('.available-shared-runners')).to have_content(shared_runner.display_name)
        end
      end
    end
77

Shinya Maeda committed
78 79 80
    context 'when a specific runner exists in another project' do
      given(:another_project) { create(:project) }
      given(:specific_runner) { create(:ci_runner, :specific) }
81

Shinya Maeda committed
82 83 84
      background do
        another_project.add_master(user)
        another_project.runners << specific_runner
85 86
      end

Shinya Maeda committed
87 88
      scenario 'user enables and disables a specific runner' do
        visit runners_path(project)
89

Shinya Maeda committed
90 91 92
        within '.available-specific-runners' do
          click_on 'Enable for this project'
        end
93

Shinya Maeda committed
94 95 96 97
        expect(page.find('.activated-specific-runners')).to have_content(specific_runner.display_name)

        within '.activated-specific-runners' do
          click_on 'Disable for this project'
98
        end
Shinya Maeda committed
99 100

        expect(page.find('.available-specific-runners')).to have_content(specific_runner.display_name)
101
      end
102 103
    end

104 105 106 107 108 109
    context 'when application settings have shared_runners_text' do
      given(:shared_runners_text) { 'custom **shared** runners description' }
      given(:shared_runners_html) { 'custom shared runners description' }

      background do
        stub_application_setting(shared_runners_text: shared_runners_text)
110
      end
111

112
      scenario 'user sees shared runners description' do
113 114
        visit runners_path(project)

115
        expect(page.find('.shared-runners-description')).to have_content(shared_runners_html)
116
      end
117 118
    end
  end
119 120 121 122 123 124 125 126 127 128 129 130

  context 'when a project has disabled shared_runners' do
    given(:project) { create(:project, shared_runners_enabled: false) }

    background do
      project.add_master(user)
    end

    scenario 'user enables shared runners' do
      visit runners_path(project)

      click_on 'Enable shared Runners'
Shinya Maeda committed
131

132 133 134
      expect(page.find('.shared-runners-description')).to have_content('Disable shared Runners')
    end
  end
135
end