From 3c0b08a83e92cee3100e54c79ad727abdc623c66 Mon Sep 17 00:00:00 2001 From: Dennis Hernandez Date: Mon, 20 Nov 2023 15:40:46 -0600 Subject: [PATCH] R2-2672 - Transfers alert should appear in the left hand menu panel. --- app/models/child.rb | 2 +- spec/models/concerns/alertable_spec.rb | 36 +++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/app/models/child.rb b/app/models/child.rb index 8b1a098f4d..8740f67e38 100644 --- a/app/models/child.rb +++ b/app/models/child.rb @@ -110,7 +110,7 @@ def self.alert_count_self(current_user) "INNER JOIN transitions ON transitions.record_type = 'Child' AND (transitions.record_id)::uuid = cases.id" ).where(transitions: { - type: Referral.name, + type: [Referral.name, Transfer.name], status: [Transition::STATUS_INPROGRESS, Transition::STATUS_ACCEPTED], transitioned_to: current_user.user_name }).ids diff --git a/spec/models/concerns/alertable_spec.rb b/spec/models/concerns/alertable_spec.rb index 8a178a4d42..46375ec692 100644 --- a/spec/models/concerns/alertable_spec.rb +++ b/spec/models/concerns/alertable_spec.rb @@ -62,7 +62,10 @@ permissions: [ Permission.new( resource: Permission::CASE, - actions: [Permission::MANAGE, Permission::REFERRAL, Permission::RECEIVE_REFERRAL] + actions: [ + Permission::MANAGE, Permission::REFERRAL, Permission::RECEIVE_REFERRAL, + Permission::TRANSFER, Permission::RECEIVE_TRANSFER + ] ) ], modules: [cp] @@ -237,6 +240,37 @@ end end + context 'Count alert from transferred cases' do + before do + Transfer.create!( + transitioned_by: 'test_user_2', transitioned_to: 'test_user_4', record: @test_class, + type: Transfer.name, consent_overridden: true + ) + child_tranferred = Child.create(name: 'bar', data: { owned_by: @user_c.user_name, module_id: 'primeromodule-cp' }) + Transfer.create!( + transitioned_by: 'test_user_3', transitioned_to: 'test_user_1', record: child_tranferred, + type: Transfer.name, consent_overridden: true + ) + end + + it 'count alert from self permissions users that has owned and transferred' do + expect(Child.alert_count(@user_a)).to eq(2) + expect(Child.alert_count_self(@user_a)).to eq(2) + end + + it 'count alert from self permissions users' do + expect(Child.alert_count(@user_d)).to eq(1) + end + + it 'count alert from user group' do + expect(Child.alert_count(@user_c)).to eq(3) + end + + it 'count alert from user agency' do + expect(Child.alert_count(@user_b)).to eq(3) + end + end + after do clean_data( SystemSettings, Alert, User, Role, Agency, Child, UserGroup,