Skip to content

Commit

Permalink
fix invitation_instructions to partner users
Browse files Browse the repository at this point in the history
  • Loading branch information
Italo Matos authored and Italo Matos committed Jul 31, 2022
1 parent 8510850 commit 7368644
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
18 changes: 14 additions & 4 deletions app/views/users/mailer/invitation_instructions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,20 @@
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<p>Hi there!</p>

<p>Your request has been approved and you're invited to become an user of the Human Essentials inventory management system!</p>
<p>Please, click the button below to accept this invitation and create a password to access your account.</p>
<% organization = @resource.partner&.organization %>
<% is_primary_partner = @resource.id == @resource.partner&.primary_user&.id %>
<p>Hello <%= @resource.email %>!</p>
<% if @resource.partner.present? && is_primary_partner %>
<p>You've been invited to become a partner organization with <strong><%= organization.name %>!</strong></p>
<p>Please click the link below to accept your invitation and create an account and you'll be able to begin requesting distributions.</p>
<strong> Please contact <%= organization.email %> if you are encountering any issues. </strong>
<% elsif @resource.partner.present? && !is_primary_partner %>
<p>You've been invited to <strong><%= @resource.partner.name %>'s</strong> account for requesting items from <strong><%= organization.name %>!</strong></p>
<p>Please click the link below to accept your invitation and create an account and you'll be able to begin requesting distributions.</p>
<% else %>
<p>Your request has been approved and you're invited to become an user of the Human Essentials inventory management system!</p>
<p>Please, click the button below to accept this invitation and create a password to access your account.</p>
<% end %>
<table role="presentation" border="0" cellpadding="0" cellspacing="0" class="btn btn-primary">
<tbody>
<tr>
Expand Down
15 changes: 12 additions & 3 deletions spec/mailers/custom_devise_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 <strong>#{user.partner.organization.name}!</strong>")
expect(mail.html_part.body).to include("You've been invited to become a partner organization with <strong>#{user.partner.organization.name}!</strong>")
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 <strong>#{user.partner.name}'s</strong> account for requesting items from <strong>#{user.partner.organization.name}!")
expect(mail.html_part.body).to include("You've been invited to <strong>#{user.partner.name}'s</strong> account for requesting items from <strong>#{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
Expand Down

0 comments on commit 7368644

Please sign in to comment.