Commit 597656ac authored by Mark Chao's avatar Mark Chao

Merge branch '273098-regulated-compliance-labels' into 'master'

Add regulated attribute to compliance frameworks

See merge request gitlab-org/gitlab!47761
parents bc93afa5 6ca98b4b
---
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 ( ...@@ -11291,6 +11291,7 @@ CREATE TABLE compliance_management_frameworks (
description text NOT NULL, description text NOT NULL,
color text NOT NULL, color text NOT NULL,
namespace_id integer NOT NULL, namespace_id integer NOT NULL,
regulated boolean DEFAULT true NOT NULL,
CONSTRAINT check_08cd34b2c2 CHECK ((char_length(color) <= 10)), CONSTRAINT check_08cd34b2c2 CHECK ((char_length(color) <= 10)),
CONSTRAINT check_1617e0b87e CHECK ((char_length(description) <= 255)), CONSTRAINT check_1617e0b87e CHECK ((char_length(description) <= 255)),
CONSTRAINT check_ab00bc2193 CHECK ((char_length(name) <= 255)) CONSTRAINT check_ab00bc2193 CHECK ((char_length(name) <= 255))
......
...@@ -64,6 +64,7 @@ module ComplianceManagement ...@@ -64,6 +64,7 @@ module ComplianceManagement
validates :name, presence: true, length: { maximum: 255 } validates :name, presence: true, length: { maximum: 255 }
validates :description, presence: true, length: { maximum: 255 } validates :description, presence: true, length: { maximum: 255 }
validates :color, color: true, allow_blank: false, length: { maximum: 10 } validates :color, color: true, allow_blank: false, length: { maximum: 10 }
validates :regulated, presence: true
validates :namespace_id, uniqueness: { scope: :name } validates :namespace_id, uniqueness: { scope: :name }
def default_framework_definition def default_framework_definition
......
...@@ -7,5 +7,6 @@ FactoryBot.define do ...@@ -7,5 +7,6 @@ FactoryBot.define do
name { 'GDPR' } 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).' } 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' } color { '#004494' }
regulated { true }
end end
end end
...@@ -13,6 +13,7 @@ RSpec.describe ComplianceManagement::Framework do ...@@ -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(:name).is_at_most(255) }
it { is_expected.to validate_length_of(:description).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_length_of(:color).is_at_most(10) }
it { is_expected.to validate_presence_of(:regulated) }
end end
describe 'color' do 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