Skip to content
代码片段 群组 项目
未验证 提交 2b32015c 编辑于 作者: Hitesh Raghuvanshi's avatar Hitesh Raghuvanshi 提交者: GitLab
浏览文件

Removing unused project frameworks controller

EE: true
Changelog: removed
上级 5e83db81
No related branches found
No related tags found
无相关合并请求
# frozen_string_literal: true
module Projects
class ComplianceFrameworksController < Projects::ApplicationController
feature_category :compliance_management
before_action :authorize_admin_compliance_framework!
def create
result = ComplianceManagement::Frameworks::AssignProjectService
.new(project, current_user, compliance_framework_params)
.execute
handle_update_result(result)
end
private
def compliance_framework_params
params.permit(:framework)
end
end
end
...@@ -155,8 +155,6 @@ ...@@ -155,8 +155,6 @@
resources :agents, path: 'agents(/*vueroute)', action: :index resources :agents, path: 'agents(/*vueroute)', action: :index
end end
resources :compliance_frameworks, only: [:create]
resources :merge_trains, only: [:index] resources :merge_trains, only: [:index]
end end
# End of the /-/ scope. # End of the /-/ scope.
......
...@@ -45,15 +45,4 @@ ...@@ -45,15 +45,4 @@
expect(response).to render_template(:edit) expect(response).to render_template(:edit)
end end
end end
describe Projects::ComplianceFrameworksController do
it 'user can assign a compliance framework to a project via a custom role' do
params = { framework: framework.id }
post project_compliance_frameworks_path(project), params: params
expect(response).to have_gitlab_http_status(:redirect)
expect(flash[:notice]).to eq("Project '#{project.name}' was successfully updated.")
end
end
end end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::ComplianceFrameworksController, feature_category: :compliance_management do
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
let_it_be(:user) { create(:user) }
let_it_be(:framework) { create(:compliance_framework, namespace: group) }
before do
stub_licensed_features(compliance_framework: true, custom_compliance_frameworks: true, custom_roles: true)
login_as(user)
end
describe 'POST #create' do
let(:params) { { framework: framework.id } }
subject(:assign_framework) { post project_compliance_frameworks_path(project), params: params }
shared_examples 'setting compliance framework' do
it 'redirects with notice message' do
assign_framework
expect(response).to redirect_to(edit_project_path(project, anchor: 'js-general-project-settings'))
expect(flash[:notice]).to eq("Project '#{project.name}' was successfully updated.")
end
it 'sets the compliance framework' do
assign_framework
expect(project.reload.compliance_framework_settings.first.compliance_management_framework).to eq(framework)
end
end
context 'when user is a project owner' do
before_all do
project.add_owner(user)
end
it_behaves_like 'setting compliance framework'
end
context 'when user has the permission because of a custom role' do
let_it_be(:role) { create(:member_role, :guest, namespace: group, admin_compliance_framework: true) }
let_it_be(:membership) { create(:group_member, :guest, member_role: role, user: user, group: group) }
it_behaves_like 'setting compliance framework'
end
context 'when user does not have permissions to update the framework' do
it 'returns a 404' do
assign_framework
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册