debian-mirror-gitlab/spec/features/admin/admin_runners_spec.rb

182 lines
4.8 KiB
Ruby
Raw Normal View History

2015-09-25 12:07:36 +05:30
require 'spec_helper'
describe "Admin Runners" do
2017-08-17 22:00:37 +05:30
include StubENV
2015-09-25 12:07:36 +05:30
before do
2017-08-17 22:00:37 +05:30
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
2017-09-10 17:25:29 +05:30
sign_in(create(:admin))
2015-09-25 12:07:36 +05:30
end
describe "Runners page" do
2017-09-10 17:25:29 +05:30
let(:pipeline) { create(:ci_pipeline) }
context "when there are runners" do
before do
runner = FactoryGirl.create(:ci_runner, contacted_at: Time.now)
FactoryGirl.create(:ci_build, pipeline: pipeline, runner_id: runner.id)
visit admin_runners_path
end
it 'has all necessary texts' do
expect(page).to have_text "How to setup"
expect(page).to have_text "Runners with last contact more than a minute ago: 1"
end
describe 'search' do
before do
FactoryGirl.create :ci_runner, description: 'runner-foo'
FactoryGirl.create :ci_runner, description: 'runner-bar'
end
it 'shows correct runner when description matches' do
search_form = find('#runners-search')
search_form.fill_in 'search', with: 'runner-foo'
search_form.click_button 'Search'
2015-09-25 12:07:36 +05:30
2017-09-10 17:25:29 +05:30
expect(page).to have_content("runner-foo")
expect(page).not_to have_content("runner-bar")
end
it 'shows no runner when description does not match' do
search_form = find('#runners-search')
search_form.fill_in 'search', with: 'runner-baz'
search_form.click_button 'Search'
expect(page).to have_text 'No runners found'
end
end
2017-08-17 22:00:37 +05:30
end
2015-09-25 12:07:36 +05:30
2017-09-10 17:25:29 +05:30
context "when there are no runners" do
2015-09-25 12:07:36 +05:30
before do
2017-09-10 17:25:29 +05:30
visit admin_runners_path
2015-09-25 12:07:36 +05:30
end
2017-09-10 17:25:29 +05:30
it 'has all necessary texts including no runner message' do
expect(page).to have_text "How to setup"
expect(page).to have_text "Runners with last contact more than a minute ago: 0"
expect(page).to have_text 'No runners found'
2017-08-17 22:00:37 +05:30
end
2015-09-25 12:07:36 +05:30
end
end
describe "Runner show page" do
let(:runner) { FactoryGirl.create :ci_runner }
before do
2017-09-10 17:25:29 +05:30
@project1 = FactoryGirl.create(:project)
@project2 = FactoryGirl.create(:project)
2015-12-23 02:04:40 +05:30
visit admin_runner_path(runner)
2015-09-25 12:07:36 +05:30
end
describe 'runner info' do
it { expect(find_field('runner_token').value).to eq runner.token }
end
describe 'projects' do
2017-08-17 22:00:37 +05:30
it 'contains project names' do
expect(page).to have_content(@project1.name_with_namespace)
expect(page).to have_content(@project2.name_with_namespace)
end
2015-09-25 12:07:36 +05:30
end
describe 'search' do
before do
search_form = find('#runner-projects-search')
2015-12-23 02:04:40 +05:30
search_form.fill_in 'search', with: @project1.name
2015-09-25 12:07:36 +05:30
search_form.click_button 'Search'
end
2017-08-17 22:00:37 +05:30
it 'contains name of correct project' do
expect(page).to have_content(@project1.name_with_namespace)
expect(page).not_to have_content(@project2.name_with_namespace)
end
2015-09-25 12:07:36 +05:30
end
2016-06-22 15:30:34 +05:30
describe 'enable/create' do
2016-08-24 12:49:21 +05:30
shared_examples 'assignable runner' do
it 'enables a runner for a project' do
within '.unassigned-projects' do
click_on 'Enable'
end
assigned_project = page.find('.assigned-projects')
expect(assigned_project).to have_content(@project2.path)
end
2016-06-22 15:30:34 +05:30
end
2016-08-24 12:49:21 +05:30
context 'with specific runner' do
before do
@project1.runners << runner
visit admin_runner_path(runner)
2016-06-22 15:30:34 +05:30
end
2016-08-24 12:49:21 +05:30
it_behaves_like 'assignable runner'
end
context 'with locked runner' do
before do
runner.update(locked: true)
@project1.runners << runner
visit admin_runner_path(runner)
end
it_behaves_like 'assignable runner'
end
context 'with shared runner' do
before do
@project1.destroy
runner.update(is_shared: true)
visit admin_runner_path(runner)
end
2016-06-22 15:30:34 +05:30
2016-08-24 12:49:21 +05:30
it_behaves_like 'assignable runner'
2016-06-22 15:30:34 +05:30
end
end
describe 'disable/destroy' do
before do
@project1.runners << runner
visit admin_runner_path(runner)
end
it 'enables specific runner for project' do
within '.assigned-projects' do
click_on 'Disable'
end
new_runner_project = page.find('.unassigned-projects')
expect(new_runner_project).to have_content(@project1.path)
end
end
2015-09-25 12:07:36 +05:30
end
2015-12-23 02:04:40 +05:30
describe 'runners registration token' do
let!(:token) { current_application_settings.runners_registration_token }
2017-09-10 17:25:29 +05:30
before do
visit admin_runners_path
end
2015-12-23 02:04:40 +05:30
it 'has a registration token' do
2017-09-10 17:25:29 +05:30
expect(page.find('#registration_token')).to have_content(token)
2015-12-23 02:04:40 +05:30
end
describe 'reload registration token' do
2017-09-10 17:25:29 +05:30
let(:page_token) { find('#registration_token').text }
2015-12-23 02:04:40 +05:30
before do
click_button 'Reset runners registration token'
end
it 'changes registration token' do
expect(page_token).not_to eq token
2015-12-23 02:04:40 +05:30
end
end
end
2015-09-25 12:07:36 +05:30
end