rubyforgood / rubyforgood/human-essentials
Investigate Custom Devise Mailer
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 593
- Forks
- 593
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 41
Description
Summary
So we have a custom devise mailer that seems to be responsible for setting the subject line for Partner invitations.. Tests for reference
The code looks something like this:
if resource.has_role?(Role::PARTNER, :any) && resource.id == resource.partner.primary_user&.id
# do something
elsif resource.has_role?(Role::PARTNER, :any) && resource.id != resource.partner.primary_user&.id
# do something else
This code (I think at least) sends one message if the user being invited is the primary user for the Partner and another if they are not.
Criteria for Completion
Figure out if this code is correct:
- Does it make sense to check for
resource.has_role?(Role::PARTNER, :any)as opposed to a specific partner - does it make sense for these invitations to get sent from a Partner vs a Org?
- Do they even get sent from a Partner and not an Org?
- If we change the code to check for a specific partner will there be any issues?
- If it seems reasonable and necessary make the change 🙂
Historical context:
The mailer was originally added here: https://github.com/rubyforgood/human-essentials/commit/ff961af7f5051ec6e05dd9cdd4d055b5e650431d. It simply changed the invite message for inviting Partners instead of Orgs.
if resource.is_a?(PartnerUser)
"You've been invited to be a partner with #{resource.partner.organization.name}"
https://github.com/rubyforgood/human-essentials/pull/2232 allowed Partners to invite coworkers by checking that the inviter was the primary user for that Partner:
if resource.is_a?(PartnerUser) && resource.id != resource.partner.primary_user&.id
"You've been invited to #{resource.partner.name}'s partnerbase account"
https://github.com/rubyforgood/human-essentials/pull/3050 got rid of PartnerUsers and instead used partner_id
if resource.try(:partner_id) && resource.id == resource.partner.primary_user&.id
"You've been invited to be a partner with #{resource.partner.organization.name}"
https://github.com/rubyforgood/human-essentials/pull/3117 finally when roles got added we started checking by role instead of partner_id
if resource.has_role?(Role::PARTNER, :any) && resource.id == resource.partner.primary_user&.id
"You've been invited to be a partner with #{resource.partner.organization.name}"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with app/mailers/custom_devise_mailer.rb and spec/mailers/custom_devise_mailer_spec.rb, then review the linked historical commits and pull requests to trace the invitation behavior. Verify each completion criterion, confirm the relevant sender and role checks, and run the mailer spec; done means the logic is justified and any necessary change is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rails, ruby
- Domain
- authentication, backend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100