Commit 6ca98b4b authored by Max Woolf's avatar Max Woolf Committed by Mark Chao

Add regulated attribute to compliance frameworks

As part of the process of adding custom compliance
frameworks, this commit adds a new database column
to determine if the framework is regulated by
law.

We're not currently using this column but it will
be definable and editable once
https://gitlab.com/gitlab-org/gitlab/-/issues/255340
is complete.
parent 1109cbcc
---
title: Add regulated field to compliance management frameworks
merge_request: 47761
author:
type: added
# frozen_string_literal: true
class AddRegulatedToComplianceFrameworks < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column(:compliance_management_frameworks, :regulated, :boolean, default: true, null: false)
end
end
39a109d2a0daaac6e5d40b13ee48f5388b85320c1ae6214408596417794307f3
\ No newline at end of file
......@@ -11291,6 +11291,7 @@ CREATE TABLE compliance_management_frameworks (
description text NOT NULL,
color text NOT NULL,
namespace_id integer NOT NULL,
regulated boolean DEFAULT true NOT NULL,
CONSTRAINT check_08cd34b2c2 CHECK ((char_length(color) <= 10)),
CONSTRAINT check_1617e0b87e CHECK ((char_length(description) <= 255)),
CONSTRAINT check_ab00bc2193 CHECK ((char_length(name) <= 255))
......
......@@ -64,6 +64,7 @@ module ComplianceManagement
validates :name, presence: true, length: { maximum: 255 }
validates :description, presence: true, length: { maximum: 255 }
validates :color, color: true, allow_blank: false, length: { maximum: 10 }
validates :regulated, presence: true
validates :namespace_id, uniqueness: { scope: :name }
def default_framework_definition
......
......@@ -7,5 +7,6 @@ FactoryBot.define do
name { 'GDPR' }
description { 'The General Data Protection Regulation (GDPR) is a regulation in EU law on data protection and privacy in the European Union (EU) and the European Economic Area (EEA).' }
color { '#004494' }
regulated { true }
end
end
......@@ -13,6 +13,7 @@ RSpec.describe ComplianceManagement::Framework do
it { is_expected.to validate_length_of(:name).is_at_most(255) }
it { is_expected.to validate_length_of(:description).is_at_most(255) }
it { is_expected.to validate_length_of(:color).is_at_most(10) }
it { is_expected.to validate_presence_of(:regulated) }
end
describe 'color' 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