Commit cadf5ceb authored by James Lopez's avatar James Lopez

Merge branch 'issue_233479_add_controller' into 'master'

Adds test cases controller and UI tab

See merge request gitlab-org/gitlab!40019
parents 7d2fe1bd 204ae6dc
...@@ -167,7 +167,7 @@ ...@@ -167,7 +167,7 @@
= render_if_exists "layouts/nav/requirements_link", project: @project = render_if_exists "layouts/nav/requirements_link", project: @project
- if project_nav_tab? :pipelines - if project_nav_tab? :pipelines
= nav_link(controller: [:pipelines, :builds, :jobs, :pipeline_schedules, :artifacts], unless: -> { current_path?('projects/pipelines#charts') }) do = nav_link(controller: [:pipelines, :builds, :jobs, :pipeline_schedules, :artifacts, :test_cases], unless: -> { current_path?('projects/pipelines#charts') }) do
= link_to project_pipelines_path(@project), class: 'shortcuts-pipelines qa-link-pipelines rspec-link-pipelines', data: { qa_selector: 'ci_cd_link' } do = link_to project_pipelines_path(@project), class: 'shortcuts-pipelines qa-link-pipelines rspec-link-pipelines', data: { qa_selector: 'ci_cd_link' } do
.nav-icon-container .nav-icon-container
= sprite_icon('rocket') = sprite_icon('rocket')
...@@ -175,7 +175,7 @@ ...@@ -175,7 +175,7 @@
= _('CI / CD') = _('CI / CD')
%ul.sidebar-sub-level-items %ul.sidebar-sub-level-items
= nav_link(controller: [:pipelines, :builds, :jobs, :pipeline_schedules, :artifacts], html_options: { class: "fly-out-top-item" }) do = nav_link(controller: [:pipelines, :builds, :jobs, :pipeline_schedules, :artifacts, :test_cases], html_options: { class: "fly-out-top-item" }) do
= link_to project_pipelines_path(@project) do = link_to project_pipelines_path(@project) do
%strong.fly-out-top-item-name %strong.fly-out-top-item-name
= _('CI / CD') = _('CI / CD')
...@@ -204,6 +204,8 @@ ...@@ -204,6 +204,8 @@
%span %span
= _('Schedules') = _('Schedules')
= render_if_exists "layouts/nav/test_cases_link", project: @project
= render_if_exists 'layouts/nav/sidebar/project_security_link' # EE-specific = render_if_exists 'layouts/nav/sidebar/project_security_link' # EE-specific
- if project_nav_tab? :operations - if project_nav_tab? :operations
......
# frozen_string_literal: true
class Projects::Quality::TestCasesController < Projects::ApplicationController
before_action :check_quality_management_available!
before_action :authorize_read_issue!
before_action :verify_test_cases_flag!
before_action do
push_frontend_feature_flag(:quality_test_cases, project)
end
def index
respond_to do |format|
format.html
end
end
private
def verify_test_cases_flag!
render_404 unless Feature.enabled?(:quality_test_cases, project)
end
end
...@@ -145,6 +145,7 @@ class License < ApplicationRecord ...@@ -145,6 +145,7 @@ class License < ApplicationRecord
subepics subepics
threat_monitoring threat_monitoring
tracing tracing
quality_management
] ]
EEU_FEATURES.freeze EEU_FEATURES.freeze
......
- return unless Feature.enabled?(:quality_test_cases, project)
- return unless project.feature_available?(:quality_management)
- return unless can?(current_user, :read_issue, project)
- if project_nav_tab?(:pipelines)
= nav_link(controller: :test_cases) do
= link_to project_quality_test_cases_path(project), title: _('Test Cases'), class: 'shortcuts-test-cases' do
%span
= _('Test Cases')
- page_title _('Test Cases')
- breadcrumb_title _("Test Cases")
---
name: quality_test_cases
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40019
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/241983
group: group::certify
type: development
default_enabled: false
\ No newline at end of file
...@@ -15,6 +15,10 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -15,6 +15,10 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources :requirements, only: [:index] resources :requirements, only: [:index]
end end
namespace :quality do
resources :test_cases, only: [:index]
end
resources :feature_flags, param: :iid do resources :feature_flags, param: :iid do
resources :feature_flag_issues, only: [:index, :create, :destroy], as: 'issues', path: 'issues' resources :feature_flag_issues, only: [:index, :create, :destroy], as: 'issues', path: 'issues'
end end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::Quality::TestCasesController do
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) }
subject { get :index, params: { namespace_id: project.namespace, project_id: project } }
describe 'GET #index' do
context 'with authorized user' do
before do
project.add_developer(user)
sign_in(user)
end
context 'when feature is available' do
before do
stub_licensed_features(quality_management: true)
end
it 'renders the index template' do
subject
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:index)
end
context 'when quality_test_cases flag is disabled' do
before do
stub_feature_flags(quality_test_cases: false)
end
it 'returns 404' do
subject
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
context 'when feature is not available' do
before do
stub_licensed_features(quality_management: false)
end
it 'returns 404' do
subject
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
context 'with unauthorized user' do
before do
sign_in(user)
end
context 'when feature is available' do
before do
stub_licensed_features(quality_management: true)
end
it 'returns 404' do
subject
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
context 'with anonymous user' do
it 'returns 302' do
subject
expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(new_user_session_path)
end
end
end
end
...@@ -24263,6 +24263,9 @@ msgstr "" ...@@ -24263,6 +24263,9 @@ msgstr ""
msgid "Test" msgid "Test"
msgstr "" msgstr ""
msgid "Test Cases"
msgstr ""
msgid "Test coverage parsing" msgid "Test coverage parsing"
msgstr "" msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment