Skip to content

Commit f59b5eb

Browse files
authored
Archived clients should not trigger external Hub notifications (#6068)
1 parent 7a36983 commit f59b5eb

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

app/services/interaction_tracking_service.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def self.record_incoming_interaction(client, set_flag: true, **attrs)
1919

2020
users_to_contact.each do |user|
2121
interaction = ClientInteraction.create!(client: client, interaction_type: interaction_type)
22-
ClientInteractionNotificationEmailJob.set(wait: 10.minutes).perform_later(interaction, user, **email_attrs)
22+
ClientInteractionNotificationEmailJob.set(wait: 10.minutes).perform_later(interaction, user, **email_attrs) unless client.has_archived_intake?
2323
end
2424
end
2525
end
@@ -56,7 +56,7 @@ def self.record_internal_interaction(client, **attrs)
5656
interaction_type: interaction_type,
5757
)
5858
)
59-
SendInternalEmailJob.perform_later(internal_email)
59+
SendInternalEmailJob.perform_later(internal_email) unless client.has_archived_intake?
6060
end
6161
end
6262

app/services/tax_return_assignment_service.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def assign!
1919
end
2020

2121
def send_notifications
22+
return if @client.has_archived_intake?
2223
if @assigned_user.present? && (@assigned_user != @assigned_by) && @assigned_user.client_assignments_notification_yes?
2324
UserNotification.create!(
2425
user: @assigned_user,

spec/services/interaction_tracking_service_spec.rb

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,20 @@
138138
end
139139
end
140140
end
141+
142+
context "when client has an archived intake" do
143+
let!(:archived_intake) { create(:archived_2021_gyr_intake, client: client) }
144+
145+
it "doesn't send any email notifications" do
146+
described_class.record_incoming_interaction(client, received_at: fake_time, interaction_type: "new_client_message")
147+
expect(ClientInteraction).to have_received(:create!).with(
148+
client: client,
149+
interaction_type: "new_client_message"
150+
)
151+
expect(ClientInteractionNotificationEmailJob).not_to have_received(:set)
152+
expect(job).not_to have_received(:perform_later)
153+
end
154+
end
141155
end
142156

143157
describe "#record_internal_interaction" do
@@ -189,7 +203,16 @@
189203
expect(internal_email.mail_class).to eq "UserMailer"
190204
expect(internal_email.mail_method).to eq "internal_interaction_notification_email"
191205
expect(internal_email.mail_args).to match_array ActiveJob::Arguments.serialize(client: client, user: user, interaction_type: "tagged_in_note", received_at: received_at)
192-
expect(SendInternalEmailJob).to have_received(:perform_later).with(internal_email)
206+
expect(SendInternalEmailJob).to have_received(:perform_later)
207+
end
208+
209+
context "when client has an archived intake" do
210+
let!(:archived_intake) { create(:archived_2021_gyr_intake, client: client) }
211+
212+
it "doesn't send any email notifications" do
213+
described_class.record_internal_interaction(client, interaction_type: "tagged_in_note", user: user, received_at: received_at)
214+
expect(SendInternalEmailJob).not_to have_received(:perform_later)
215+
end
193216
end
194217
end
195218
end

spec/services/tax_return_assignment_service_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,17 @@
120120
}.not_to change(InternalEmail, :count).from(0)
121121
end
122122
end
123+
124+
context "when client has an archived intake" do
125+
before do
126+
allow_any_instance_of(Client).to receive(:has_archived_intake?).and_return true
127+
end
128+
129+
it "does not send email" do
130+
expect {
131+
subject.send_notifications
132+
}.not_to change(InternalEmail, :count).from(0)
133+
end
134+
end
123135
end
124136
end

0 commit comments

Comments
 (0)