Skip to content

Commit

Permalink
Merged in r2-2672-count-transfer-alerts (pull request #6604)
Browse files Browse the repository at this point in the history
R2-2672 - Transfers alert should appear in the left hand menu panel.
  • Loading branch information
dhernandez-quoin authored and pnabutovsky committed Nov 21, 2023
2 parents a54cdd9 + 3c0b08a commit e0ecef0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/child.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 35 additions & 1 deletion spec/models/concerns/alertable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e0ecef0

Please sign in to comment.