diff --git a/app/models/user.rb b/app/models/user.rb index 2fd63c71d..5defc6129 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -37,6 +37,14 @@ class User < ApplicationRecord last_sign_in_at ? RESET_PASSWORD_TEMPLATE_ID : SET_PASSWORD_TEMPLATE_ID end + def is_key_contact? + is_key_contact + end + + def is_key_contact! + update(is_key_contact: true) + end + def is_data_protection_officer? is_dpo end diff --git a/db/migrate/20220329125601_add_key_contact_field_to_user.rb b/db/migrate/20220329125601_add_key_contact_field_to_user.rb new file mode 100644 index 000000000..15634e574 --- /dev/null +++ b/db/migrate/20220329125601_add_key_contact_field_to_user.rb @@ -0,0 +1,7 @@ +class AddKeyContactFieldToUser < ActiveRecord::Migration[7.0] + def change + change_table :users, bulk: true do |t| + t.column :is_key_contact, :boolean, default: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index c5592dc25..22e8ed704 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -316,6 +316,7 @@ ActiveRecord::Schema[7.0].define(version: 202202071123100) do t.string "unlock_token" t.datetime "locked_at", precision: nil t.boolean "is_dpo", default: false + t.boolean "is_key_contact", default: false t.string "phone" t.index ["email"], name: "index_users_on_email", unique: true t.index ["organisation_id"], name: "index_users_on_organisation_id" diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index a59cd8fdd..275bb540c 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -47,13 +47,17 @@ RSpec.describe User, type: :model do expect(user.data_coordinator?).to be false end + it "is not a key contact by default" do + expect(user.is_key_contact?).to be false + end + it "is not a data protection officer by default" do expect(user.is_data_protection_officer?).to be false end - it "can be set to data protection officer" do - expect { user.is_data_protection_officer! } - .to change { user.reload.is_data_protection_officer? }.from(false).to(true) + it "can be set to key contact" do + expect { user.is_key_contact! } + .to change { user.reload.is_key_contact? }.from(false).to(true) end end