2021-09-30 23:02:18 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe 'projects/runners/specific_runners.html.haml' do
|
|
|
|
describe 'render' do
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
context 'when project runner registration is allowed' do
|
|
|
|
before do
|
|
|
|
stub_application_setting(valid_runner_registrars: ['project'])
|
2022-05-07 20:08:51 +05:30
|
|
|
allow(view).to receive(:can?).with(user, :register_project_runners, project).and_return(true)
|
2021-09-30 23:02:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'enables the Remove project button for a project' do
|
|
|
|
render 'projects/runners/specific_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
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
it 'does not enable the Remove project button for a project' do
|
2021-09-30 23:02:18 +05:30
|
|
|
render 'projects/runners/specific_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
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|