runners_spec.rb 1.7 KB
Newer Older
D
Douwe Maan 已提交
1 2 3 4
require 'spec_helper'

describe "Admin Runners" do
  before do
V
Valery Sizov 已提交
5
    skip_ci_admin_auth
D
Douwe Maan 已提交
6 7 8 9 10
    login_as :user
  end

  describe "Runners page" do
    before do
V
Valery Sizov 已提交
11 12 13 14
      runner = FactoryGirl.create(:ci_runner)
      commit = FactoryGirl.create(:ci_commit)
      FactoryGirl.create(:ci_build, commit: commit, runner_id: runner.id)
      visit ci_admin_runners_path
D
Douwe Maan 已提交
15 16 17 18 19 20 21 22
    end

    it { page.has_text? "Manage Runners" }
    it { page.has_text? "To register a new runner" }
    it { page.has_text? "Runners with last contact less than a minute ago: 1" }

    describe 'search' do
      before do
V
Valery Sizov 已提交
23 24
        FactoryGirl.create :ci_runner, description: 'foo'
        FactoryGirl.create :ci_runner, description: 'bar'
D
Douwe Maan 已提交
25

26 27 28
        search_form = find('#runners-search')
        search_form.fill_in 'search', with: 'foo'
        search_form.click_button 'Search'
D
Douwe Maan 已提交
29 30
      end

31 32
      it { expect(page).to have_content("foo") }
      it { expect(page).not_to have_content("bar") }
D
Douwe Maan 已提交
33 34 35 36
    end
  end

  describe "Runner show page" do
V
Valery Sizov 已提交
37
    let(:runner) { FactoryGirl.create :ci_runner }
D
Douwe Maan 已提交
38 39

    before do
V
Valery Sizov 已提交
40 41 42
      FactoryGirl.create(:ci_project, name: "foo")
      FactoryGirl.create(:ci_project, name: "bar")
      visit ci_admin_runner_path(runner)
D
Douwe Maan 已提交
43 44 45
    end

    describe 'runner info' do
46
      it { expect(find_field('runner_token').value).to eq runner.token }
D
Douwe Maan 已提交
47 48 49
    end

    describe 'projects' do
50 51
      it { expect(page).to have_content("foo") }
      it { expect(page).to have_content("bar") }
D
Douwe Maan 已提交
52 53 54 55
    end

    describe 'search' do
      before do
56 57 58
        search_form = find('#runner-projects-search')
        search_form.fill_in 'search', with: 'foo'
        search_form.click_button 'Search'
D
Douwe Maan 已提交
59 60
      end

61 62
      it { expect(page).to have_content("foo") }
      it { expect(page).not_to have_content("bar") }
D
Douwe Maan 已提交
63 64 65
    end
  end
end