Skip to content

Commit

Permalink
feat(helpscout): warn when instructeur disabled notifs
Browse files Browse the repository at this point in the history
  • Loading branch information
colinux committed Oct 1, 2024
1 parent 4830769 commit 1ece87d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/controllers/webhook_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ def helpscout
if instructeur
url = manager_instructeur_url(instructeur)
html << link_to_manager(instructeur, url)

instructeur.assign_to.each do |assign_to|
if !assign_to.instant_email_dossier_notifications_enabled ||
!assign_to.instant_email_message_notifications_enabled ||
!assign_to.instant_expert_avis_email_notifications_enabled
html << "Notifs désactivées Procedure##{assign_to.groupe_instructeur.procedure_id}"
end
end

Check warning on line 51 in app/controllers/webhook_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/webhook_controller.rb#L45-L51

Added lines #L45 - L51 were not covered by tests
end

if administrateur
Expand Down
14 changes: 14 additions & 0 deletions spec/controllers/webhook_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@
expect(payload['html']).to have_selector("a[href='#{manager_administrateur_url(admin)}']")
end
end

context "when notifications are disabled" do
let(:instructeur) { create(:instructeur, user:) }
let(:procedure) { create(:procedure) }
before do
create(:assign_to, instructeur:, procedure:,
instant_email_dossier_notifications_enabled: false
)
end

it 'returns a summary of disabled notifications' do
expect(payload['html']).to have_text("Notifs désactivées Procedure##{procedure.id}")
end
end
end
end

Expand Down

0 comments on commit 1ece87d

Please sign in to comment.