debian-mirror-gitlab/spec/views/projects/runners/_project_runners.html.haml_spec.rb

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

82 lines
2.8 KiB
Ruby
Raw Normal View History

2021-09-30 23:02:18 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-04-23 21:23:45 +05:30
RSpec.describe 'projects/runners/_project_runners.html.haml', feature_category: :runner do
2021-09-30 23:02:18 +05:30
describe 'render' do
2023-04-23 21:23:45 +05:30
let_it_be(:user) { build(:user) }
let_it_be(:project) { build(:project) }
2021-09-30 23:02:18 +05:30
before do
@project = project
@assignable_runners = []
@project_runners = []
2022-05-07 20:08:51 +05:30
allow(view).to receive(:current_user).and_return(user)
2021-09-30 23:02:18 +05:30
allow(view).to receive(:reset_registration_token_namespace_project_settings_ci_cd_path).and_return('banana_url')
end
2023-07-09 08:55:56 +05:30
context 'when create_runner_workflow_for_namespace is disabled' do
2021-09-30 23:02:18 +05:30
before do
2023-07-09 08:55:56 +05:30
stub_feature_flags(create_runner_workflow_for_namespace: false)
2021-09-30 23:02:18 +05:30
end
2023-07-09 08:55:56 +05:30
context 'when project runner registration is allowed' do
before do
stub_application_setting(valid_runner_registrars: ['project'])
allow(view).to receive(:can?).with(user, :register_project_runners, project).and_return(true)
end
2021-09-30 23:02:18 +05:30
2023-07-09 08:55:56 +05:30
it 'enables the Remove project button for a project' do
render 'projects/runners/project_runners', project: project
expect(rendered).to have_selector '#js-install-runner'
expect(rendered).not_to have_content 'Please contact an admin to register runners.'
end
end
context 'when project runner registration is not allowed' do
before do
stub_application_setting(valid_runner_registrars: ['group'])
end
it 'does not enable the Remove project button for a project' do
render 'projects/runners/project_runners', project: project
expect(rendered).to have_content 'Please contact an admin to register runners.'
expect(rendered).not_to have_selector '#js-install-runner'
end
2021-09-30 23:02:18 +05:30
end
end
2023-07-09 08:55:56 +05:30
context 'when create_runner_workflow_for_namespace is enabled' do
2021-09-30 23:02:18 +05:30
before do
2023-07-09 08:55:56 +05:30
stub_feature_flags(create_runner_workflow_for_namespace: project.namespace)
2021-09-30 23:02:18 +05:30
end
2023-07-09 08:55:56 +05:30
context 'when user can create project runner' do
before do
allow(view).to receive(:can?).with(user, :create_runner, project).and_return(true)
end
it 'renders the New project runner button' do
render 'projects/runners/project_runners', project: project
expect(rendered).to have_link(s_('Runners|New project runner'), href: new_project_runner_path(project))
end
end
context 'when user cannot create project runner' do
before do
allow(view).to receive(:can?).with(user, :create_runner, project).and_return(false)
end
it 'does not render the New project runner button' do
render 'projects/runners/project_runners', project: project
2021-09-30 23:02:18 +05:30
2023-07-09 08:55:56 +05:30
expect(rendered).not_to have_link(s_('Runners|New project runner'))
end
2021-09-30 23:02:18 +05:30
end
end
end
end