Commit c1f12ff5 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch...

Merge branch 'fix/sm/36731-improve-spec-spec-features-runners_spec-rb-and-spec-features-admin-admin_runners_spec-rb' into 'master'

Reorganizes spec: spec/features/runners_spec.rb

Closes #36731

See merge request !13716
parents eae604e6 fab3df77
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
- if runner.locked? - if runner.locked?
= icon('lock', class: 'has-tooltip', title: 'Locked to current projects') = icon('lock', class: 'has-tooltip', title: 'Locked to current projects')
%small %small.edit-runner
= link_to edit_project_runner_path(@project, runner) do = link_to edit_project_runner_path(@project, runner) do
%i.fa.fa-edit.btn %i.fa.fa-edit.btn
- else - else
......
require 'spec_helper' require 'spec_helper'
describe "Runners" do feature 'Runners' do
let(:user) { create(:user) } given(:user) { create(:user) }
before do background do
sign_in(user) sign_in(user)
end end
describe "specific runners" do context 'when a project has enabled shared_runners' do
before do given(:project) { create(:project) }
@project = FactoryGirl.create :project, shared_runners_enabled: false
@project.team << [user, :master]
@project2 = FactoryGirl.create :project background do
@project2.team << [user, :master] project.add_master(user)
end
@project3 = FactoryGirl.create :project context 'when a specific runner is activated on the project' do
@project3.team << [user, :developer] given(:specific_runner) { create(:ci_runner, :specific) }
@shared_runner = FactoryGirl.create :ci_runner, :shared background do
@specific_runner = FactoryGirl.create :ci_runner project.runners << specific_runner
@specific_runner2 = FactoryGirl.create :ci_runner end
@specific_runner3 = FactoryGirl.create :ci_runner
@project.runners << @specific_runner
@project2.runners << @specific_runner2
@project3.runners << @specific_runner3
visit runners_path(@project) scenario 'user sees the specific runner' do
end visit runners_path(project)
before do within '.activated-specific-runners' do
expect(page).not_to have_content(@specific_runner3.display_name) expect(page).to have_content(specific_runner.display_name)
expect(page).not_to have_content(@specific_runner3.display_name) end
end
it "places runners in right places" do click_on specific_runner.short_sha
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 expect(page).to have_content(specific_runner.platform)
within ".available-specific-runners" do
click_on "Enable for this project"
end end
expect(page.find(".activated-specific-runners")).to have_content(@specific_runner2.display_name) scenario 'user removes an activated specific runner if this is last project for that runners' do
end visit runners_path(project)
it "disables specific runner for project" do within '.activated-specific-runners' do
@project2.runners << @specific_runner click_on 'Remove Runner'
visit runners_path(@project) end
within ".activated-specific-runners" do expect(page).not_to have_content(specific_runner.display_name)
click_on "Disable for this project"
end end
expect(page.find(".available-specific-runners")).to have_content(@specific_runner.display_name) context 'when a runner has a tag' do
end background do
specific_runner.update(tag_list: ['tag'])
end
it "removes specific runner for project if this is last project for that runners" do scenario 'user edits runner not to run untagged jobs' do
within ".activated-specific-runners" do visit runners_path(project)
click_on "Remove Runner"
end
expect(Ci::Runner.exists?(id: @specific_runner)).to be_falsey within '.activated-specific-runners' do
end first('.edit-runner > a').click
end end
describe "shared runners" do expect(page.find_field('runner[run_untagged]')).to be_checked
before do
@project = FactoryGirl.create :project, shared_runners_enabled: false
@project.team << [user, :master]
visit runners_path(@project)
end
it "enables shared runners" do uncheck 'runner_run_untagged'
click_on "Enable shared Runners" click_button 'Save changes'
expect(@project.reload.shared_runners_enabled).to be_truthy
end
end
describe "shared runners description" do expect(page).to have_content 'Can run untagged jobs No'
let(:shared_runners_text) { 'custom **shared** runners description' } end
let(:shared_runners_html) { 'custom shared runners description' } end
before do context 'when a shared runner is activated on the project' do
stub_application_setting(shared_runners_text: shared_runners_text) given!(:shared_runner) { create(:ci_runner, :shared) }
project = FactoryGirl.create :project, shared_runners_enabled: false
project.team << [user, :master]
visit runners_path(project)
end
it "sees shared runners description" do scenario 'user sees CI/CD setting page' do
expect(page.find(".shared-runners-description")).to have_content(shared_runners_html) visit runners_path(project)
end
end
describe "show page" do expect(page.find('.available-shared-runners')).to have_content(shared_runner.display_name)
before do end
@project = FactoryGirl.create :project end
@project.team << [user, :master]
@specific_runner = FactoryGirl.create :ci_runner
@project.runners << @specific_runner
end end
it "shows runner information" do context 'when a specific runner exists in another project' do
visit runners_path(@project) given(:another_project) { create(:project) }
click_on @specific_runner.short_sha given(:specific_runner) { create(:ci_runner, :specific) }
expect(page).to have_content(@specific_runner.platform)
end
end
feature 'configuring runners ability to picking untagged jobs' do background do
given(:project) { create(:project) } another_project.add_master(user)
given(:runner) { create(:ci_runner) } another_project.runners << specific_runner
end
background do scenario 'user enables and disables a specific runner' do
project.team << [user, :master] visit runners_path(project)
project.runners << runner
end within '.available-specific-runners' do
click_on 'Enable for this project'
end
scenario 'user checks default configuration' do expect(page.find('.activated-specific-runners')).to have_content(specific_runner.display_name)
visit project_runner_path(project, runner)
expect(page).to have_content 'Can run untagged jobs Yes' 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
end end
context 'when runner has tags' do context 'when application settings have shared_runners_text' do
before do given(:shared_runners_text) { 'custom **shared** runners description' }
runner.update_attribute(:tag_list, ['tag']) given(:shared_runners_html) { 'custom shared runners description' }
background do
stub_application_setting(shared_runners_text: shared_runners_text)
end end
scenario 'user wants to prevent runner from running untagged job' do scenario 'user sees shared runners description' do
visit runners_path(project) visit runners_path(project)
page.within('.activated-specific-runners') do
first('small > a').click
end
uncheck 'runner_run_untagged' expect(page.find('.shared-runners-description')).to have_content(shared_runners_html)
click_button 'Save changes'
expect(page).to have_content 'Can run untagged jobs No'
expect(runner.reload.run_untagged?).to eq false
end end
end end
end end
context 'when a project has disabled shared_runners' do
given(:project) { create(:project, shared_runners_enabled: false) }
background do
project.add_master(user)
end
scenario 'user enables shared runners' do
visit runners_path(project)
click_on 'Enable shared Runners'
expect(page.find('.shared-runners-description')).to have_content('Disable shared Runners')
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment