diff options
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/admin/runners_controller_spec.rb | 26 | ||||
-rw-r--r-- | spec/controllers/groups/runners_controller_spec.rb | 106 | ||||
-rw-r--r-- | spec/controllers/projects/runners_controller_spec.rb | 106 |
3 files changed, 56 insertions, 182 deletions
diff --git a/spec/controllers/admin/runners_controller_spec.rb b/spec/controllers/admin/runners_controller_spec.rb index b1a2d90589a..6fa8d2c61c1 100644 --- a/spec/controllers/admin/runners_controller_spec.rb +++ b/spec/controllers/admin/runners_controller_spec.rb @@ -41,18 +41,6 @@ RSpec.describe Admin::RunnersController, feature_category: :runner_fleet do expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template(:new) end - - context 'when create_runner_workflow_for_admin is disabled' do - before do - stub_feature_flags(create_runner_workflow_for_admin: false) - end - - it 'returns :not_found' do - get :new - - expect(response).to have_gitlab_http_status(:not_found) - end - end end describe '#register' do @@ -78,20 +66,6 @@ RSpec.describe Admin::RunnersController, feature_category: :runner_fleet do expect(response).to have_gitlab_http_status(:not_found) end end - - context 'when create_runner_workflow_for_admin is disabled' do - let_it_be(:new_runner) { create(:ci_runner, registration_type: :authenticated_user) } - - before do - stub_feature_flags(create_runner_workflow_for_admin: false) - end - - it 'returns :not_found' do - register - - expect(response).to have_gitlab_http_status(:not_found) - end - end end describe '#edit' do diff --git a/spec/controllers/groups/runners_controller_spec.rb b/spec/controllers/groups/runners_controller_spec.rb index 9ae5cb6f87c..37242bce6bf 100644 --- a/spec/controllers/groups/runners_controller_spec.rb +++ b/spec/controllers/groups/runners_controller_spec.rb @@ -65,52 +65,28 @@ RSpec.describe Groups::RunnersController, feature_category: :runner_fleet do end describe '#new' do - context 'when create_runner_workflow_for_namespace is enabled' do + context 'when user is owner' do before do - stub_feature_flags(create_runner_workflow_for_namespace: [group]) - end - - context 'when user is owner' do - before do - group.add_owner(user) - end - - it 'renders new with 200 status code' do - get :new, params: { group_id: group } - - expect(response).to have_gitlab_http_status(:ok) - expect(response).to render_template(:new) - end + group.add_owner(user) end - context 'when user is not owner' do - before do - group.add_maintainer(user) - end - - it 'renders a 404' do - get :new, params: { group_id: group } + it 'renders new with 200 status code' do + get :new, params: { group_id: group } - expect(response).to have_gitlab_http_status(:not_found) - end + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template(:new) end end - context 'when create_runner_workflow_for_namespace is disabled' do + context 'when user is not owner' do before do - stub_feature_flags(create_runner_workflow_for_namespace: false) + group.add_maintainer(user) end - context 'when user is owner' do - before do - group.add_owner(user) - end - - it 'renders a 404' do - get :new, params: { group_id: group } + it 'renders a 404' do + get :new, params: { group_id: group } - expect(response).to have_gitlab_http_status(:not_found) - end + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -118,66 +94,40 @@ RSpec.describe Groups::RunnersController, feature_category: :runner_fleet do describe '#register' do subject(:register) { get :register, params: { group_id: group, id: new_runner } } - context 'when create_runner_workflow_for_namespace is enabled' do + context 'when user is owner' do before do - stub_feature_flags(create_runner_workflow_for_namespace: [group]) + group.add_owner(user) end - context 'when user is owner' do - before do - group.add_owner(user) - end - - context 'when runner can be registered after creation' do - let_it_be(:new_runner) { create(:ci_runner, :group, groups: [group], registration_type: :authenticated_user) } + context 'when runner can be registered after creation' do + let_it_be(:new_runner) { create(:ci_runner, :group, groups: [group], 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 + it 'renders a :register template' do + register - expect(response).to have_gitlab_http_status(:not_found) - end + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template(:register) end end - context 'when user is not owner' do - before do - group.add_maintainer(user) - end - - context 'when runner can be registered after creation' do - let_it_be(:new_runner) { create(:ci_runner, :group, groups: [group], registration_type: :authenticated_user) } + context 'when runner cannot be registered after creation' do + let_it_be(:new_runner) { runner } - it 'returns :not_found' do - register + it 'returns :not_found' do + register - expect(response).to have_gitlab_http_status(:not_found) - end + expect(response).to have_gitlab_http_status(:not_found) end end end - context 'when create_runner_workflow_for_namespace is disabled' do - let_it_be(:new_runner) { create(:ci_runner, :group, groups: [group], registration_type: :authenticated_user) } - + context 'when user is not owner' do before do - stub_feature_flags(create_runner_workflow_for_namespace: false) + group.add_maintainer(user) end - context 'when user is owner' do - before do - group.add_owner(user) - end + context 'when runner can be registered after creation' do + let_it_be(:new_runner) { create(:ci_runner, :group, groups: [group], registration_type: :authenticated_user) } it 'returns :not_found' do register diff --git a/spec/controllers/projects/runners_controller_spec.rb b/spec/controllers/projects/runners_controller_spec.rb index e0e4d0f7bc5..d6816bd49af 100644 --- a/spec/controllers/projects/runners_controller_spec.rb +++ b/spec/controllers/projects/runners_controller_spec.rb @@ -28,52 +28,28 @@ RSpec.describe Projects::RunnersController, feature_category: :runner_fleet do } end - context 'when create_runner_workflow_for_namespace is enabled' do + context 'when user is maintainer' do before do - stub_feature_flags(create_runner_workflow_for_namespace: [project.namespace]) + project.add_maintainer(user) end - context 'when user is maintainer' do - before do - project.add_maintainer(user) - end - - it 'renders new with 200 status code' do - get :new, params: params + it 'renders new with 200 status code' do + get :new, params: params - expect(response).to have_gitlab_http_status(:ok) - expect(response).to render_template(:new) - end - end - - context 'when user is not maintainer' do - before do - project.add_developer(user) - end - - it 'renders a 404' do - get :new, params: params - - expect(response).to have_gitlab_http_status(:not_found) - end + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template(:new) end end - context 'when create_runner_workflow_for_namespace is disabled' do + context 'when user is not maintainer' do before do - stub_feature_flags(create_runner_workflow_for_namespace: false) + project.add_developer(user) end - context 'when user is maintainer' do - before do - project.add_maintainer(user) - end + it 'renders a 404' do + get :new, params: params - it 'renders a 404' do - get :new, params: params - - expect(response).to have_gitlab_http_status(:not_found) - end + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -81,66 +57,40 @@ RSpec.describe Projects::RunnersController, feature_category: :runner_fleet do 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 + context 'when user is maintainer' do before do - stub_feature_flags(create_runner_workflow_for_namespace: [project.namespace]) + project.add_maintainer(user) 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 } + 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 + it 'renders a :register template' do + register - expect(response).to have_gitlab_http_status(:not_found) - end + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template(:register) 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) } + context 'when runner cannot be registered after creation' do + let_it_be(:new_runner) { runner } - it 'returns :not_found' do - register + it 'returns :not_found' do + register - expect(response).to have_gitlab_http_status(:not_found) - end + expect(response).to have_gitlab_http_status(:not_found) 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) } - + context 'when user is not maintainer' do before do - stub_feature_flags(create_runner_workflow_for_namespace: false) + project.add_developer(user) 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 'returns :not_found' do register |