Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor mailers #1105

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Refactor mailers #1105

wants to merge 4 commits into from

Conversation

Kizr
Copy link
Contributor

@Kizr Kizr commented Oct 11, 2024

Context

We need some more flexibility in our mailers so different services can send different emails to different types of users.

Changes proposed in this pull request

  • Create Claims::ApplicationMailer and Placements::ApplicationMailer which split out the service dependent logic.
  • Create Claims::UserMailer and Placements::UserMailer which inherit from thier service specific application mailer
  • Remove UserMailer
  • Create Claims::SupportUserMailer and Placements::SupportUserMailer which inherit from thier service specific application mailer
  • Remove SupportUserMailer
  • Create user_mailer_class and support_user_mailer_class methods to find the correct mailer to use for the current service
  • Refactor all mailer usages to point at their service specific mailer classes.
  • Refactor all mailer specs to mirror this logic

Guidance to review

On the claims and placements services:

  • Log in as Colin
  • Navigate to Settings
  • Ensure all mailers are displaying correctly

Link to Trello card

Refactor email notifications to be service specific

Creates the Claims::ApplicationMailer and Placements::Application which inherit from ApplicationMailer and moves service specific methods into their respectively namespaced application mailer.
Creates the Placements::SupportUserMailer and Claims::SupportUserMailer, also removes the original SupportUserMailer. This is because the service mailers are going to diverge in the near future, so translation files and logic has been split.
Creates the Placements::UserMailer and Claims::UserMailer, also removes the original UserMailer. This is because the service mailers are going to diverge in the near future, so translation files and logic has been split.
@Kizr Kizr added the deploy A Review App will be created for PRs with this label label Oct 11, 2024
@Kizr Kizr self-assigned this Oct 11, 2024
@Kizr Kizr requested review from a team as code owners October 11, 2024 15:32
Copy link

Comment on lines 11 to 30

private

def user_mailer_class(service)
case service
when :placements
Placements::UserMailer
when :claims
Claims::UserMailer
end
end

def support_user_mailer_class(service)
case service
when :placements
Placements::SupportUserMailer
when :claims
Claims::SupportUserMailer
end
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do we think these should live? They're only relevant to services and each method is used in two services. Maybe these could live in the application mailer instead?

Removes service param from mailer calls and replaces it with the appropriate mailer class. Adds a method to return the correct mailer class in service objects and refactors tests to accommodate this change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy A Review App will be created for PRs with this label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant