BigW Consortium Gitlab

runners_spec.rb 3.58 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
require 'spec_helper'

describe "Runners" do
  include GitlabRoutingHelper

  let(:user) { create(:user) }
  before { login_as(user) }

  describe "specific runners" do
    before do
11 12
      @project = FactoryGirl.create :empty_project, shared_runners_enabled: false
      @project.team << [user, :master]
13

14 15
      @project2 = FactoryGirl.create :empty_project
      @project2.team << [user, :master]
16

17 18
      @project3 = FactoryGirl.create :empty_project
      @project3.team << [user, :developer]
19

20 21 22 23
      @shared_runner = FactoryGirl.create :ci_runner, :shared
      @specific_runner = FactoryGirl.create :ci_runner
      @specific_runner2 = FactoryGirl.create :ci_runner
      @specific_runner3 = FactoryGirl.create :ci_runner
24 25 26
      @project.runners << @specific_runner
      @project2.runners << @specific_runner2
      @project3.runners << @specific_runner3
27

28
      visit runners_path(@project)
29 30
    end

31 32 33 34 35
    before do
      expect(page).to_not have_content(@specific_runner3.display_name)
      expect(page).to_not have_content(@specific_runner3.display_name)
    end

36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
    it "places runners in right places" do
      expect(page.find(".available-specific-runners")).to have_content(@specific_runner2.display_name)
      expect(page.find(".activated-specific-runners")).to have_content(@specific_runner.display_name)
      expect(page.find(".available-shared-runners")).to have_content(@shared_runner.display_name)
    end

    it "enables specific runner for project" do
      within ".available-specific-runners" do
        click_on "Enable for this project"
      end

      expect(page.find(".activated-specific-runners")).to have_content(@specific_runner2.display_name)
    end

    it "disables specific runner for project" do
51
      @project2.runners << @specific_runner
52
      visit runners_path(@project)
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

      within ".activated-specific-runners" do
        click_on "Disable for this project"
      end

      expect(page.find(".available-specific-runners")).to have_content(@specific_runner.display_name)
    end

    it "removes specific runner for project if this is last project for that runners" do
      within ".activated-specific-runners" do
        click_on "Remove runner"
      end

      expect(Ci::Runner.exists?(id: @specific_runner)).to be_falsey
    end
  end

  describe "shared runners" do
    before do
72 73 74
      @project = FactoryGirl.create :empty_project, shared_runners_enabled: false
      @project.team << [user, :master]
      visit runners_path(@project)
75 76 77 78 79 80 81 82
    end

    it "enables shared runners" do
      click_on "Enable shared runners"
      expect(@project.reload.shared_runners_enabled).to be_truthy
    end
  end

83
  describe "shared runners description" do
84 85
    let(:shared_runners_text) { 'custom **shared** runners description' }
    let(:shared_runners_html) { 'custom shared runners description' }
86 87

    before do
88 89 90 91
      stub_application_setting(shared_runners_text: shared_runners_text)
      project = FactoryGirl.create :empty_project, shared_runners_enabled: false
      project.team << [user, :master]
      visit runners_path(project)
92 93 94
    end

    it "sees shared runners description" do
95
      expect(page.find(".shared-runners-description")).to have_content(shared_runners_html)
96 97 98
    end
  end

99 100
  describe "show page" do
    before do
101 102
      @project = FactoryGirl.create :empty_project
      @project.team << [user, :master]
103
      @specific_runner = FactoryGirl.create :ci_runner
104
      @project.runners << @specific_runner
105 106 107
    end

    it "shows runner information" do
108
      visit runners_path(@project)
109 110 111 112 113
      click_on @specific_runner.short_sha
      expect(page).to have_content(@specific_runner.platform)
    end
  end
end