diff --git a/app/models/user.rb b/app/models/user.rb index 159be7e70..f60baf072 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -25,12 +25,17 @@ class User < ApplicationRecord data_accessor: 0, data_provider: 1, data_coordinator: 2, + support: 99 }.freeze enum role: ROLES def case_logs - CaseLog.for_organisation(organisation) + if support? + CaseLog.all + else + CaseLog.for_organisation(organisation) + end end def completed_case_logs diff --git a/spec/factories/user.rb b/spec/factories/user.rb index 0de22af97..9b8edb23f 100644 --- a/spec/factories/user.rb +++ b/spec/factories/user.rb @@ -11,6 +11,9 @@ FactoryBot.define do trait :data_protection_officer do is_dpo { true } end + trait :support do + role { "support" } + end created_at { Time.zone.now } updated_at { Time.zone.now } end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 99d27529a..a898e7950 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -64,6 +64,14 @@ RSpec.describe User, type: :model do expect { user.is_data_protection_officer! } .to change { user.reload.is_data_protection_officer? }.from(false).to(true) end + context "when the user is a Customer Support person" do + let(:user) { FactoryBot.create(:user, :support) } + let!(:other_orgs_log) { FactoryBot.create(:case_log) } + + it "has access to logs from all organisations" do + expect(user.case_logs.to_a).to eq([owned_case_log, managed_case_log, other_orgs_log]) + end + end end describe "paper trail" do