diff --git a/app/views/users/mailer/invitation_instructions.html.erb b/app/views/users/mailer/invitation_instructions.html.erb index 5367fb0f52..395e935b50 100644 --- a/app/views/users/mailer/invitation_instructions.html.erb +++ b/app/views/users/mailer/invitation_instructions.html.erb @@ -341,10 +341,20 @@
-

Hi there!

- -

Your request has been approved and you're invited to become an user of the Human Essentials inventory management system!

-

Please, click the button below to accept this invitation and create a password to access your account.

+ <% organization = @resource.partner&.organization %> + <% is_primary_partner = @resource.id == @resource.partner&.primary_user&.id %> +

Hello <%= @resource.email %>!

+ <% if @resource.partner.present? && is_primary_partner %> +

You've been invited to become a partner organization with <%= organization.name %>!

+

Please click the link below to accept your invitation and create an account and you'll be able to begin requesting distributions.

+ Please contact <%= organization.email %> if you are encountering any issues. + <% elsif @resource.partner.present? && !is_primary_partner %> +

You've been invited to <%= @resource.partner.name %>'s account for requesting items from <%= organization.name %>!

+

Please click the link below to accept your invitation and create an account and you'll be able to begin requesting distributions.

+ <% else %> +

Your request has been approved and you're invited to become an user of the Human Essentials inventory management system!

+

Please, click the button below to accept this invitation and create a password to access your account.

+ <% end %> diff --git a/spec/mailers/custom_devise_mailer_spec.rb b/spec/mailers/custom_devise_mailer_spec.rb index a1c0066839..fceb45a210 100644 --- a/spec/mailers/custom_devise_mailer_spec.rb +++ b/spec/mailers/custom_devise_mailer_spec.rb @@ -15,17 +15,26 @@ it "invites to primary user" do expect(mail.subject).to eq("You've been invited to be a partner with #{user.partner.organization.name}") - # expect(mail.html_part.body).to include("You've been invited to become a partner organization with #{user.partner.organization.name}!") + expect(mail.html_part.body).to include("You've been invited to become a partner organization with #{user.partner.organization.name}!") end end - context "when invited by other partner users" do + context "when other partner users invited" do let(:partner) { create(:partner) } let(:user) { create(:user, partner: partner.profile) } it "invites to partner user" do expect(mail.subject).to eq("You've been invited to #{user.partner.name}'s partnerbase account") - # expect(mail.html_part.body).to include("You've been invited to #{user.partner.name}'s account for requesting items from #{user.partner.organization.name}!") + expect(mail.html_part.body).to include("You've been invited to #{user.partner.name}'s account for requesting items from #{user.partner.organization.name}!") + end + end + + context "when user is invited" do + let(:user) { create(:user) } + + it "invites to user" do + expect(mail.subject).to eq("Your Human Essentials App Account Approval") + expect(mail.html_part.body).to include("Your request has been approved and you're invited to become an user of the Human Essentials inventory management system!") end end end