Commit dfa611f0 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Merge branch 'bwill/rename-policies-list-view' into 'master'

Rename PoliciesController#show to PoliciesController#index

See merge request gitlab-org/gitlab!67929
parents 8a0389fe b35fa8a7
......@@ -15,8 +15,8 @@ module Projects
feature_category :security_orchestration
def show
render :show, locals: { project: project }
def index
render :index, locals: { project: project }
end
def edit
......@@ -38,8 +38,8 @@ module Projects
if result[:status] == :error
case result[:invalid_component]
when :policy_configuration
redirect_to project_security_policy_path(project), alert: result[:message]
when :policy_configuration, :parameter
redirect_to project_security_policies_path(project), alert: result[:message]
when :policy_project
redirect_to project_path(policy_configuration.security_policy_management_project)
when :policy_yaml
......@@ -48,12 +48,7 @@ module Projects
redirect_to project_blob_path(policy_management_project, policy_path), alert: result[:message]
else
# We should redirect to security policies list view once it is implemented.
# For now, we will render_404
# This case also covers `when :parameter`
# redirect_to project_security_policies_path(project), alert: result[:message]
render_404
redirect_to project_security_policies_path(project), alert: result[:message]
end
end
end
......
- add_to_breadcrumbs s_("SecurityOrchestration|Policies"), project_security_policy_path(@project)
- add_to_breadcrumbs s_("SecurityOrchestration|Policies"), project_security_policies_path(@project)
- breadcrumb_title s_("SecurityOrchestration|Edit policy")
- page_title s_("SecurityOrchestration|Edit policy")
- data = orchestration_policy_data(@project, @policy_type, @policy, @environment)
......
- add_to_breadcrumbs s_("SecurityOrchestration|Policies"), project_security_policy_path(@project)
- add_to_breadcrumbs s_("SecurityOrchestration|Policies"), project_security_policies_path(@project)
- breadcrumb_title s_("SecurityOrchestration|New policy")
- page_title s_("SecurityOrchestration|Policy editor")
- policy_details = policy_details(@project)
......
......@@ -59,10 +59,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources :dashboard, only: [:index], controller: :dashboard
resources :vulnerability_report, only: [:index], controller: :vulnerability_report
resource :policy, only: [:show]
resources :policies, only: [:new, :edit], controller: :policies, constraints: { id: %r{[^/]+} }
resources :policies, only: [:index, :new, :edit], constraints: { id: %r{[^/]+} }
resource :configuration, only: [], controller: :configuration do
post :auto_fix, on: :collection
......
......@@ -150,7 +150,7 @@ module EE
::Sidebars::MenuItem.new(
title: _('Policies'),
link: project_security_policy_path(context.project),
link: project_security_policies_path(context.project),
active_routes: { controller: ['projects/security/policies'] },
item_id: :scan_policies
)
......
......@@ -21,7 +21,7 @@ RSpec.describe Projects::Security::PoliciesController, type: :request do
end
let_it_be(:type) { 'scan_execution_policy' }
let_it_be(:show) { project_security_policy_url(project) }
let_it_be(:index) { project_security_policies_url(project) }
let_it_be(:edit) { edit_project_security_policy_url(project, id: policy[:name], type: type) }
let_it_be(:new) { new_project_security_policy_url(project) }
......@@ -102,10 +102,20 @@ RSpec.describe Projects::Security::PoliciesController, type: :request do
context 'when type is missing' do
let_it_be(:edit) { edit_project_security_policy_url(project, id: policy[:name]) }
it 'returns 404' do
it 'redirects to #index' do
get edit
expect(response).to have_gitlab_http_status(:not_found)
expect(response).to redirect_to(project_security_policies_path(project))
end
end
context 'when type is invalid' do
let_it_be(:edit) { edit_project_security_policy_url(project, id: policy[:name], type: 'invalid') }
it 'redirects to #index' do
get edit
expect(response).to redirect_to(project_security_policies_path(project))
end
end
......@@ -124,10 +134,10 @@ RSpec.describe Projects::Security::PoliciesController, type: :request do
let_it_be(:policy_configuration) { nil }
let_it_be(:edit) { edit_project_security_policy_url(project, id: policy[:name], type: type) }
it 'redirects to policy configuration page' do
it 'redirects to #index' do
get edit
expect(response).to redirect_to(project_security_policy_path(project))
expect(response).to redirect_to(project_security_policies_path(project))
end
end
......@@ -229,7 +239,7 @@ RSpec.describe Projects::Security::PoliciesController, type: :request do
end
end
describe 'GET #show' do
describe 'GET #index' do
using RSpec::Parameterized::TableSyntax
where(:feature_flag, :license, :status) do
......@@ -239,7 +249,7 @@ RSpec.describe Projects::Security::PoliciesController, type: :request do
true | false | :not_found
end
subject(:request) { get show, params: { namespace_id: project.namespace, project_id: project } }
subject(:request) { get index, params: { namespace_id: project.namespace, project_id: project } }
with_them do
before do
......
......@@ -74,8 +74,8 @@ RSpec.describe 'EE-specific project routing' do
expect(get("/gitlab/gitlabhq/-/security/policies/new")).to route_to('projects/security/policies#new', namespace_id: 'gitlab', project_id: 'gitlabhq')
end
it 'to #show' do
expect(get('/gitlab/gitlabhq/-/security/policy')).to route_to('projects/security/policies#show', namespace_id: 'gitlab', project_id: 'gitlabhq')
it 'to #index' do
expect(get('/gitlab/gitlabhq/-/security/policies')).to route_to('projects/security/policies#index', namespace_id: 'gitlab', project_id: 'gitlabhq')
end
with_them do
......
......@@ -204,7 +204,7 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
it 'policies link is visible' do
expect(rendered).to have_link('Policies', href: project_security_policy_path(project))
expect(rendered).to have_link('Policies', href: project_security_policies_path(project))
end
it 'security configuration link is visible' do
......
......@@ -2,14 +2,14 @@
require 'spec_helper'
RSpec.describe "projects/security/policies/show", type: :view do
RSpec.describe "projects/security/policies/index", type: :view do
let(:user) { project.owner }
let(:project) { create(:project) }
before do
stub_feature_flags(security_orchestration_policies_configuration: true)
sign_in(user)
render template: 'projects/security/policies/show', locals: { project: project }
render template: 'projects/security/policies/index', locals: { project: project }
end
it 'renders Vue app root' do
......
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