debian-mirror-gitlab/spec/views/shared/runners/_runner_details.html.haml_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

149 lines
4.4 KiB
Ruby
Raw Permalink Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-07-09 08:55:56 +05:30
RSpec.describe 'shared/runners/_runner_details.html.haml', feature_category: :runner_fleet do
2018-12-13 13:39:08 +05:30
include PageLayoutHelper
2023-07-09 08:55:56 +05:30
let_it_be(:runner) do
build_stubbed(
2023-06-20 00:43:36 +05:30
:ci_runner,
name: 'test runner',
version: '11.4.0',
ip_address: '127.1.2.3',
revision: 'abcd1234',
architecture: 'amd64'
)
2018-12-13 13:39:08 +05:30
end
before do
2021-06-08 01:23:25 +05:30
allow(view).to receive(:runner) { runner }
2018-12-13 13:39:08 +05:30
end
subject do
render
rendered
end
describe 'Runner id and type' do
context 'when runner is of type instance' do
2021-04-29 21:17:54 +05:30
it { is_expected.to have_content("Runner ##{runner.id} shared") }
2018-12-13 13:39:08 +05:30
end
context 'when runner is of type group' do
2023-07-09 08:55:56 +05:30
let(:runner) { build_stubbed(:ci_runner, :group) }
2018-12-13 13:39:08 +05:30
2021-04-29 21:17:54 +05:30
it { is_expected.to have_content("Runner ##{runner.id} group") }
2018-12-13 13:39:08 +05:30
end
context 'when runner is of type project' do
2023-07-09 08:55:56 +05:30
let(:runner) { build_stubbed(:ci_runner, :project) }
2018-12-13 13:39:08 +05:30
2023-04-23 21:23:45 +05:30
it { is_expected.to have_content("Runner ##{runner.id} project") }
2018-12-13 13:39:08 +05:30
end
end
describe 'Active value' do
context 'when runner is active' do
it { is_expected.to have_content('Active Yes') }
end
context 'when runner is inactive' do
2023-07-09 08:55:56 +05:30
let(:runner) { build_stubbed(:ci_runner, :inactive) }
2018-12-13 13:39:08 +05:30
it { is_expected.to have_content('Active No') }
end
end
describe 'Protected value' do
context 'when runner is not protected' do
it { is_expected.to have_content('Protected No') }
end
context 'when runner is protected' do
2023-07-09 08:55:56 +05:30
let(:runner) { build_stubbed(:ci_runner, :ref_protected) }
2018-12-13 13:39:08 +05:30
it { is_expected.to have_content('Protected Yes') }
end
end
describe 'Can run untagged jobs value' do
context 'when runner run untagged job is set' do
it { is_expected.to have_content('Can run untagged jobs Yes') }
end
context 'when runner run untagged job is unset' do
2023-07-09 08:55:56 +05:30
let(:runner) { build_stubbed(:ci_runner, :tagged_only) }
2018-12-13 13:39:08 +05:30
it { is_expected.to have_content('Can run untagged jobs No') }
end
end
describe 'Locked to this project value' do
context 'when runner locked is not set' do
it { is_expected.to have_content('Locked to this project No') }
context 'when runner is of type group' do
2023-07-09 08:55:56 +05:30
let(:runner) { build_stubbed(:ci_runner, :group) }
2018-12-13 13:39:08 +05:30
it { is_expected.not_to have_content('Locked to this project') }
end
end
context 'when runner locked is set' do
2023-07-09 08:55:56 +05:30
let(:runner) { build_stubbed(:ci_runner, :locked) }
2018-12-13 13:39:08 +05:30
it { is_expected.to have_content('Locked to this project Yes') }
context 'when runner is of type group' do
2023-07-09 08:55:56 +05:30
let(:runner) { build_stubbed(:ci_runner, :group, :locked) }
2018-12-13 13:39:08 +05:30
it { is_expected.not_to have_content('Locked to this project') }
end
end
end
describe 'Tags value' do
context 'when runner does not have tags' do
it { is_expected.to have_content('Tags') }
2022-10-11 01:57:18 +05:30
it { is_expected.not_to have_selector('span.gl-badge.badge.badge-info') }
2018-12-13 13:39:08 +05:30
end
context 'when runner have tags' do
2023-07-09 08:55:56 +05:30
let(:runner) { build_stubbed(:ci_runner, tag_list: %w[tag2 tag3 tag1]) }
2018-12-13 13:39:08 +05:30
it { is_expected.to have_content('Tags tag1 tag2 tag3') }
2022-10-11 01:57:18 +05:30
it { is_expected.to have_selector('span.gl-badge.badge.badge-info') }
2018-12-13 13:39:08 +05:30
end
end
describe 'Metadata values' do
it { is_expected.to have_content("Name #{runner.name}") }
it { is_expected.to have_content("Version #{runner.version}") }
it { is_expected.to have_content("IP Address #{runner.ip_address}") }
it { is_expected.to have_content("Revision #{runner.revision}") }
it { is_expected.to have_content("Platform #{runner.platform}") }
it { is_expected.to have_content("Architecture #{runner.architecture}") }
it { is_expected.to have_content("Description #{runner.description}") }
end
describe 'Maximum job timeout value' do
2023-07-09 08:55:56 +05:30
let(:runner) { build_stubbed(:ci_runner, maximum_timeout: 5400) }
2018-12-13 13:39:08 +05:30
it { is_expected.to have_content('Maximum job timeout 1h 30m') }
end
describe 'Last contact value' do
context 'when runner have not contacted yet' do
it { is_expected.to have_content('Last contact Never') }
end
context 'when runner have already contacted' do
2023-07-09 08:55:56 +05:30
let(:runner) { build_stubbed(:ci_runner, contacted_at: DateTime.now - 6.days) }
2021-06-08 01:23:25 +05:30
let(:expected_contacted_at) { I18n.l(runner.contacted_at, format: "%b %d, %Y") }
2018-12-13 13:39:08 +05:30
it { is_expected.to have_content("Last contact #{expected_contacted_at}") }
end
end
end