summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-04-25 18:08:55 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-04-25 18:08:55 +0000
commit1e3f5ab634699e9d50779f05d2ae8dfc8a3ab9b3 (patch)
treec96727e136f4dc4fdbc1190895439d41e0b07fc5 /spec/controllers
parentba8e92f7c9938d7dba333d2396cdd14bfa0de726 (diff)
downloadgitlab-ce-1e3f5ab634699e9d50779f05d2ae8dfc8a3ab9b3.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/projects/runners_controller_spec.rb79
1 files changed, 76 insertions, 3 deletions
diff --git a/spec/controllers/projects/runners_controller_spec.rb b/spec/controllers/projects/runners_controller_spec.rb
index 2edb41b7119..e0e4d0f7bc5 100644
--- a/spec/controllers/projects/runners_controller_spec.rb
+++ b/spec/controllers/projects/runners_controller_spec.rb
@@ -3,9 +3,9 @@
require 'spec_helper'
RSpec.describe Projects::RunnersController, feature_category: :runner_fleet do
- let(:user) { create(:user) }
- let(:project) { create(:project) }
- let(:runner) { create(:ci_runner, :project, projects: [project]) }
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project) }
+ let_it_be(:runner) { create(:ci_runner, :project, projects: [project]) }
let(:params) do
{
@@ -78,6 +78,79 @@ RSpec.describe Projects::RunnersController, feature_category: :runner_fleet do
end
end
+ describe '#register' do
+ subject(:register) { get :register, params: { namespace_id: project.namespace, project_id: project, id: new_runner } }
+
+ context 'when create_runner_workflow_for_namespace is enabled' do
+ before do
+ stub_feature_flags(create_runner_workflow_for_namespace: [project.namespace])
+ end
+
+ context 'when user is maintainer' do
+ before do
+ project.add_maintainer(user)
+ end
+
+ context 'when runner can be registered after creation' do
+ let_it_be(:new_runner) { create(:ci_runner, :project, projects: [project], registration_type: :authenticated_user) }
+
+ it 'renders a :register template' do
+ register
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(response).to render_template(:register)
+ end
+ end
+
+ context 'when runner cannot be registered after creation' do
+ let_it_be(:new_runner) { runner }
+
+ it 'returns :not_found' do
+ register
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
+ end
+
+ context 'when user is not maintainer' do
+ before do
+ project.add_developer(user)
+ end
+
+ context 'when runner can be registered after creation' do
+ let_it_be(:new_runner) { create(:ci_runner, :project, projects: [project], registration_type: :authenticated_user) }
+
+ it 'returns :not_found' do
+ register
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
+ end
+ end
+
+ context 'when create_runner_workflow_for_namespace is disabled' do
+ let_it_be(:new_runner) { create(:ci_runner, :project, projects: [project], registration_type: :authenticated_user) }
+
+ before do
+ stub_feature_flags(create_runner_workflow_for_namespace: false)
+ end
+
+ context 'when user is maintainer' do
+ before do
+ project.add_maintainer(user)
+ end
+
+ it 'returns :not_found' do
+ register
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
+ end
+ end
+
describe '#update' do
it 'updates the runner and ticks the queue' do
new_desc = runner.description.swapcase