Commit daf53c85 authored by Aishwarya Subramanian's avatar Aishwarya Subramanian

Updated policy for compliance framework

For gitlab.com, licenses are applied to
namespaces as opposed to instances.
This MR fixes the policy for compliance
framework by checking license and feature
flag at namespace level.
parent bd31641c
...@@ -5,7 +5,8 @@ module ComplianceManagement ...@@ -5,7 +5,8 @@ module ComplianceManagement
delegate { @subject.namespace } delegate { @subject.namespace }
condition(:custom_compliance_frameworks_enabled) do condition(:custom_compliance_frameworks_enabled) do
License.feature_available?(:custom_compliance_frameworks) && Feature.enabled?(:ff_custom_compliance_frameworks) @subject.namespace.feature_available?(:custom_compliance_frameworks) &&
Feature.enabled?(:ff_custom_compliance_frameworks, @subject.namespace)
end end
rule { can?(:owner_access) & custom_compliance_frameworks_enabled }.policy do rule { can?(:owner_access) & custom_compliance_frameworks_enabled }.policy do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe ComplianceManagement::FrameworkPolicy do RSpec.describe ComplianceManagement::FrameworkPolicy do
let_it_be(:framework) { create(:compliance_framework) } let_it_be_with_refind(:framework) { create(:compliance_framework) }
let(:user) { framework.namespace.owner } let(:user) { framework.namespace.owner }
subject { described_class.new(user, framework) } subject { described_class.new(user, framework) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe ComplianceManagement::Frameworks::CreateService do RSpec.describe ComplianceManagement::Frameworks::CreateService do
let_it_be(:namespace) { create(:namespace) } let_it_be_with_refind(:namespace) { create(:namespace) }
let(:params) do let(:params) do
{ {
name: 'GDPR', name: 'GDPR',
...@@ -35,7 +35,7 @@ RSpec.describe ComplianceManagement::Frameworks::CreateService do ...@@ -35,7 +35,7 @@ RSpec.describe ComplianceManagement::Frameworks::CreateService do
end end
context 'namespace has a parent' do context 'namespace has a parent' do
let_it_be(:namespace) { create(:namespace, :with_hierarchy) } let_it_be_with_reload(:namespace) { create(:namespace, :with_hierarchy) }
let(:descendant) { namespace.descendants.first } let(:descendant) { namespace.descendants.first }
subject { described_class.new(namespace: descendant, params: params, current_user: namespace.owner) } subject { described_class.new(namespace: descendant, params: params, current_user: namespace.owner) }
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe ComplianceManagement::Frameworks::DestroyService do RSpec.describe ComplianceManagement::Frameworks::DestroyService do
let_it_be(:namespace) { create(:namespace) } let_it_be_with_refind(:namespace) { create(:namespace) }
let_it_be(:framework) { create(:compliance_framework, namespace: namespace) } let_it_be_with_refind(:framework) { create(:compliance_framework, namespace: namespace) }
context 'when feature is disabled' do context 'when feature is disabled' do
before do before do
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe ComplianceManagement::Frameworks::UpdateService do RSpec.describe ComplianceManagement::Frameworks::UpdateService do
let_it_be(:namespace) { create(:namespace) } let_it_be_with_refind(:namespace) { create(:namespace) }
let_it_be(:framework) { create(:compliance_framework, namespace: namespace) } let_it_be_with_refind(:framework) { create(:compliance_framework, namespace: namespace) }
let(:current_user) { namespace.owner } let(:current_user) { namespace.owner }
let(:params) { { color: '#000001', description: 'New Description', name: 'New Name' } } let(:params) { { color: '#000001', description: 'New Description', name: 'New Name' } }
......
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