2015-09-28 05:01:45 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe "Runners" do
|
|
|
|
let(:user) { create(:user) }
|
2017-06-14 14:18:56 -04:00
|
|
|
|
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2017-06-14 14:18:56 -04:00
|
|
|
end
|
2015-09-28 05:01:45 -04:00
|
|
|
|
|
|
|
describe "specific runners" do
|
|
|
|
before do
|
2017-08-02 15:55:11 -04:00
|
|
|
@project = FactoryGirl.create :project, shared_runners_enabled: false
|
2015-12-04 06:55:23 -05:00
|
|
|
@project.team << [user, :master]
|
2015-09-28 05:01:45 -04:00
|
|
|
|
2017-08-02 15:55:11 -04:00
|
|
|
@project2 = FactoryGirl.create :project
|
2015-12-04 06:55:23 -05:00
|
|
|
@project2.team << [user, :master]
|
2015-09-28 05:01:45 -04:00
|
|
|
|
2017-08-02 15:55:11 -04:00
|
|
|
@project3 = FactoryGirl.create :project
|
2015-12-04 06:55:23 -05:00
|
|
|
@project3.team << [user, :developer]
|
2015-11-16 07:24:36 -05:00
|
|
|
|
2016-02-17 16:56:33 -05:00
|
|
|
@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
|
2015-12-10 11:44:06 -05:00
|
|
|
@project.runners << @specific_runner
|
|
|
|
@project2.runners << @specific_runner2
|
|
|
|
@project3.runners << @specific_runner3
|
2015-09-28 05:01:45 -04:00
|
|
|
|
2015-12-04 06:55:23 -05:00
|
|
|
visit runners_path(@project)
|
2015-09-28 05:01:45 -04:00
|
|
|
end
|
|
|
|
|
2015-11-16 07:24:36 -05:00
|
|
|
before do
|
2016-05-23 19:37:59 -04:00
|
|
|
expect(page).not_to have_content(@specific_runner3.display_name)
|
|
|
|
expect(page).not_to have_content(@specific_runner3.display_name)
|
2015-11-16 07:24:36 -05:00
|
|
|
end
|
|
|
|
|
2015-09-28 05:01:45 -04:00
|
|
|
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
|
2015-12-10 11:44:06 -05:00
|
|
|
@project2.runners << @specific_runner
|
2015-12-04 06:55:23 -05:00
|
|
|
visit runners_path(@project)
|
2015-09-28 05:01:45 -04:00
|
|
|
|
|
|
|
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
|
2015-11-10 16:23:49 -05:00
|
|
|
click_on "Remove Runner"
|
2015-09-28 05:01:45 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(Ci::Runner.exists?(id: @specific_runner)).to be_falsey
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "shared runners" do
|
|
|
|
before do
|
2017-08-02 15:55:11 -04:00
|
|
|
@project = FactoryGirl.create :project, shared_runners_enabled: false
|
2015-12-04 06:55:23 -05:00
|
|
|
@project.team << [user, :master]
|
|
|
|
visit runners_path(@project)
|
2015-09-28 05:01:45 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "enables shared runners" do
|
2015-11-10 16:23:49 -05:00
|
|
|
click_on "Enable shared Runners"
|
2015-09-28 05:01:45 -04:00
|
|
|
expect(@project.reload.shared_runners_enabled).to be_truthy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-04-15 09:51:41 -04:00
|
|
|
describe "shared runners description" do
|
2016-04-19 07:39:53 -04:00
|
|
|
let(:shared_runners_text) { 'custom **shared** runners description' }
|
|
|
|
let(:shared_runners_html) { 'custom shared runners description' }
|
2016-04-15 09:51:41 -04:00
|
|
|
|
|
|
|
before do
|
2016-04-18 09:56:38 -04:00
|
|
|
stub_application_setting(shared_runners_text: shared_runners_text)
|
2017-08-02 15:55:11 -04:00
|
|
|
project = FactoryGirl.create :project, shared_runners_enabled: false
|
2016-04-18 09:56:38 -04:00
|
|
|
project.team << [user, :master]
|
|
|
|
visit runners_path(project)
|
2016-04-15 09:51:41 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "sees shared runners description" do
|
2016-04-19 07:39:53 -04:00
|
|
|
expect(page.find(".shared-runners-description")).to have_content(shared_runners_html)
|
2016-04-15 09:51:41 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-28 05:01:45 -04:00
|
|
|
describe "show page" do
|
|
|
|
before do
|
2017-08-02 15:55:11 -04:00
|
|
|
@project = FactoryGirl.create :project
|
2015-12-04 06:55:23 -05:00
|
|
|
@project.team << [user, :master]
|
2016-02-17 16:56:33 -05:00
|
|
|
@specific_runner = FactoryGirl.create :ci_runner
|
2015-12-10 11:44:06 -05:00
|
|
|
@project.runners << @specific_runner
|
2015-09-28 05:01:45 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "shows runner information" do
|
2015-12-04 06:55:23 -05:00
|
|
|
visit runners_path(@project)
|
2015-09-28 05:01:45 -04:00
|
|
|
click_on @specific_runner.short_sha
|
|
|
|
expect(page).to have_content(@specific_runner.platform)
|
|
|
|
end
|
|
|
|
end
|
2016-05-05 06:20:33 -04:00
|
|
|
|
|
|
|
feature 'configuring runners ability to picking untagged jobs' do
|
2017-08-02 15:55:11 -04:00
|
|
|
given(:project) { create(:project) }
|
2016-05-05 06:20:33 -04:00
|
|
|
given(:runner) { create(:ci_runner) }
|
|
|
|
|
|
|
|
background do
|
|
|
|
project.team << [user, :master]
|
|
|
|
project.runners << runner
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'user checks default configuration' do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_runner_path(project, runner)
|
2016-05-05 06:20:33 -04:00
|
|
|
|
|
|
|
expect(page).to have_content 'Can run untagged jobs Yes'
|
|
|
|
end
|
|
|
|
|
2016-05-06 02:41:51 -04:00
|
|
|
context 'when runner has tags' do
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
|
|
|
runner.update_attribute(:tag_list, ['tag'])
|
|
|
|
end
|
2016-05-05 06:20:33 -04:00
|
|
|
|
2016-05-19 15:27:52 -04:00
|
|
|
scenario 'user wants to prevent runner from running untagged job' do
|
2016-05-06 02:41:51 -04:00
|
|
|
visit runners_path(project)
|
|
|
|
page.within('.activated-specific-runners') do
|
|
|
|
first('small > a').click
|
|
|
|
end
|
2016-05-05 06:20:33 -04:00
|
|
|
|
2016-05-06 02:41:51 -04:00
|
|
|
uncheck 'runner_run_untagged'
|
|
|
|
click_button 'Save changes'
|
|
|
|
|
|
|
|
expect(page).to have_content 'Can run untagged jobs No'
|
|
|
|
expect(runner.reload.run_untagged?).to eq false
|
|
|
|
end
|
2016-05-05 06:20:33 -04:00
|
|
|
end
|
|
|
|
end
|
2015-09-28 05:01:45 -04:00
|
|
|
end
|