BigW Consortium Gitlab

runners_spec.rb 4.19 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

Shinya Maeda committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
      scenario 'user edits the runner to be protected' do
        visit runners_path(project)

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

        expect(page.find_field('runner[access_level]')).not_to be_checked

        check 'runner_access_level'
        click_button 'Save changes'

        expect(page).to have_content 'Protected Yes'
      end

61 62
      context 'when a runner has a tag' do
        background do
Shinya Maeda committed
63
          specific_runner.update(tag_list: ['tag'])
64
        end
65

66 67
        scenario 'user edits runner not to run untagged jobs' do
          visit runners_path(project)
68

69 70 71
          within '.activated-specific-runners' do
            first('.edit-runner > a').click
          end
72

73
          expect(page.find_field('runner[run_untagged]')).to be_checked
74

75 76
          uncheck 'runner_run_untagged'
          click_button 'Save changes'
77

78 79 80
          expect(page).to have_content 'Can run untagged jobs No'
        end
      end
81

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

Shinya Maeda committed
85
        scenario 'user sees CI/CD setting page' do
86
          visit runners_path(project)
87

Shinya Maeda committed
88 89 90 91
          expect(page.find('.available-shared-runners')).to have_content(shared_runner.display_name)
        end
      end
    end
92

Shinya Maeda committed
93 94 95
    context 'when a specific runner exists in another project' do
      given(:another_project) { create(:project) }
      given(:specific_runner) { create(:ci_runner, :specific) }
96

Shinya Maeda committed
97 98 99
      background do
        another_project.add_master(user)
        another_project.runners << specific_runner
100 101
      end

Shinya Maeda committed
102 103
      scenario 'user enables and disables a specific runner' do
        visit runners_path(project)
104

Shinya Maeda committed
105 106 107
        within '.available-specific-runners' do
          click_on 'Enable for this project'
        end
108

Shinya Maeda committed
109 110 111 112
        expect(page.find('.activated-specific-runners')).to have_content(specific_runner.display_name)

        within '.activated-specific-runners' do
          click_on 'Disable for this project'
113
        end
Shinya Maeda committed
114 115

        expect(page.find('.available-specific-runners')).to have_content(specific_runner.display_name)
116
      end
117 118
    end

119 120 121 122 123 124
    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)
125
      end
126

127
      scenario 'user sees shared runners description' do
128 129
        visit runners_path(project)

130
        expect(page.find('.shared-runners-description')).to have_content(shared_runners_html)
131
      end
132 133
    end
  end
134 135 136 137 138 139 140 141 142 143 144 145

  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
146

147 148 149
      expect(page.find('.shared-runners-description')).to have_content('Disable shared Runners')
    end
  end
150
end