Commit 4b59a5aa authored by Kushal Pandya's avatar Kushal Pandya

Add route `/new` under Test Cases

Adds route `/new` under Test Cases to show create
test case form.
parent 99a7757c
# frozen_string_literal: true
class Projects::Quality::TestCasesController < Projects::ApplicationController
prepend_before_action :authenticate_user!, only: [:new]
before_action :check_quality_management_available!
before_action :authorize_read_issue!
before_action :verify_test_cases_flag!
before_action :authorize_create_issue!, only: [:new]
before_action do
push_frontend_feature_flag(:quality_test_cases, project)
end
......@@ -14,6 +18,12 @@ class Projects::Quality::TestCasesController < Projects::ApplicationController
end
end
def new
respond_to do |format|
format.html
end
end
private
def verify_test_cases_flag!
......
- add_to_breadcrumbs _('Test Cases'), project_quality_test_cases_path(@project)
- breadcrumb_title _('New')
- page_title _('New Test Case')
#js-create-test-case{ data: { project_full_path: @project.full_path,
project_test_cases_path: project_quality_test_cases_path(@project),
description_preview_path: preview_markdown_path(@project),
description_help_path: help_page_path('user/markdown'),
labels_manage_path: project_labels_path(@project),
labels_fetch_path: project_labels_path(@project, format: :json) } }
......@@ -16,7 +16,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
namespace :quality do
resources :test_cases, only: [:index]
resources :test_cases, only: [:index, :new]
end
resources :autocomplete_sources, only: [] do
......
......@@ -6,9 +6,7 @@ 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
shared_examples_for 'test case action' do |template|
context 'with authorized user' do
before do
project.add_developer(user)
......@@ -20,11 +18,11 @@ RSpec.describe Projects::Quality::TestCasesController do
stub_licensed_features(quality_management: true)
end
it 'renders the index template' do
it 'renders the template' do
subject
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:index)
expect(response).to render_template(template)
end
context 'when quality_test_cases flag is disabled' do
......@@ -80,4 +78,18 @@ RSpec.describe Projects::Quality::TestCasesController do
end
end
end
describe 'GET' do
describe '#index' do
subject { get :index, params: { namespace_id: project.namespace, project_id: project } }
it_behaves_like 'test case action', :index
end
describe '#new' do
subject { get :new, params: { namespace_id: project.namespace, project_id: project } }
it_behaves_like 'test case action', :new
end
end
end
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