summaryrefslogtreecommitdiff
path: root/spec/features/runners_spec.rb
blob: c312f83c251b74f6a7bb53903744122db09c834c (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
require 'spec_helper'

describe "Runners" do
  before do
    login_as :user
  end

  describe "specific runners" do
    before do
      @project = FactoryGirl.create :project
      @project2 = FactoryGirl.create :project
      stub_js_gitlab_calls

      @shared_runner = FactoryGirl.create :shared_runner
      @specific_runner = FactoryGirl.create :specific_runner
      @specific_runner2 = FactoryGirl.create :specific_runner
      @project.runners << @specific_runner
      @project2.runners << @specific_runner2
    end

    it "places runners in right places" do
      visit project_runners_path(@project)
      page.find(".available-specific-runners").should have_content(@specific_runner2.display_name)
      page.find(".activated-specific-runners").should have_content(@specific_runner.display_name)
      page.find(".available-shared-runners").should have_content(@shared_runner.display_name)
    end

    it "enables specific runner for project" do
      visit project_runners_path(@project)

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

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

    it "disables specific runner for project" do
      @project2.runners << @specific_runner

      visit project_runners_path(@project)

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

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

    it "removes specific runner for project if this is last project for that runners" do
      visit project_runners_path(@project)

      within ".activated-specific-runners" do
        click_on "Remove runner"
      end

      Runner.exists?(id: @specific_runner).should be_false
    end
  end

  describe "shared runners" do
    before do
      @project = FactoryGirl.create :project
      stub_js_gitlab_calls
    end

    it "enables shared runners" do
      visit project_runners_path(@project)

      click_on "Enable shared runners"

      @project.reload.shared_runners_enabled.should be_true
    end
  end

  describe "show page" do
    before do
      @project = FactoryGirl.create :project
      stub_js_gitlab_calls
      @specific_runner = FactoryGirl.create :specific_runner
      @project.runners << @specific_runner
    end

    it "shows runner information" do
      visit project_runners_path(@project)

      click_on @specific_runner.short_sha

      page.should have_content(@specific_runner.platform)
    end
  end
end