Browse Source

A support role exists that can see all case logs

pull/454/head
baarkerlounger 3 years ago
parent
commit
966caa066c
  1. 7
      app/models/user.rb
  2. 3
      spec/factories/user.rb
  3. 8
      spec/models/user_spec.rb

7
app/models/user.rb

@ -25,12 +25,17 @@ class User < ApplicationRecord
data_accessor: 0, data_accessor: 0,
data_provider: 1, data_provider: 1,
data_coordinator: 2, data_coordinator: 2,
support: 99
}.freeze }.freeze
enum role: ROLES enum role: ROLES
def case_logs def case_logs
CaseLog.for_organisation(organisation) if support?
CaseLog.all
else
CaseLog.for_organisation(organisation)
end
end end
def completed_case_logs def completed_case_logs

3
spec/factories/user.rb

@ -11,6 +11,9 @@ FactoryBot.define do
trait :data_protection_officer do trait :data_protection_officer do
is_dpo { true } is_dpo { true }
end end
trait :support do
role { "support" }
end
created_at { Time.zone.now } created_at { Time.zone.now }
updated_at { Time.zone.now } updated_at { Time.zone.now }
end end

8
spec/models/user_spec.rb

@ -64,6 +64,14 @@ RSpec.describe User, type: :model do
expect { user.is_data_protection_officer! } expect { user.is_data_protection_officer! }
.to change { user.reload.is_data_protection_officer? }.from(false).to(true) .to change { user.reload.is_data_protection_officer? }.from(false).to(true)
end 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 end
describe "paper trail" do describe "paper trail" do

Loading…
Cancel
Save