|
1 | 1 | RSpec.describe CustomDeviseMailer, type: :mailer do |
2 | 2 | describe "#invitation_instructions" do |
3 | 3 | let(:user) { create(:partner_user) } |
4 | | - let(:invitation_sent_at) { nil } |
| 4 | + # let(:invitation_sent_at) { nil } |
5 | 5 | let(:mail) { described_class.invitation_instructions(user, SecureRandom.uuid) } |
6 | 6 |
|
7 | 7 | context "when partner is invited" do |
|
14 | 14 | end |
15 | 15 |
|
16 | 16 | let(:user) do |
17 | | - create(:partner_user, partner: partner, invitation_sent_at: invitation_sent_at) |
| 17 | + create(:partner_user, partner: partner) |
18 | 18 | end |
19 | 19 |
|
20 | 20 | it "invites to primary user" do |
|
26 | 26 |
|
27 | 27 | context "when other partner users invited" do |
28 | 28 | let(:partner) { create(:partner) } |
29 | | - let(:user) { create(:partner_user, partner: partner, invitation_sent_at: invitation_sent_at) } |
| 29 | + let(:user) { create(:partner_user, partner: partner) } |
30 | 30 |
|
31 | 31 | it "invites to partner user" do |
32 | 32 | expect(mail.subject).to eq("You've been invited to #{user.partner.name}'s Human Essentials account") |
33 | 33 | 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}!") |
34 | 34 | end |
35 | 35 | end |
36 | 36 |
|
37 | | - context "when user is re-invited" do |
| 37 | + context "when user is invited" do |
38 | 38 | let(:invitation_sent_at) { Time.zone.now } |
39 | 39 | let(:user) { create(:user, invitation_sent_at: invitation_sent_at) } |
40 | | - let(:role_name) { "org_user" } |
41 | 40 |
|
42 | 41 | it "invites to user" do |
43 | | - expect(mail.subject).to eq("You've been re-invited to be a #{role_name} in your Human Essentials App Account") |
44 | | - expect(mail.html_part.body).to include("You've been re-invited to become a <strong>#{role_name}</strong> in your Human Essentials App Account") |
45 | | - end |
46 | | - |
47 | | - it "has invite expiration message and reset instructions" do |
48 | | - expect(mail.html_part.body).to include("This invitation will expire at #{user.invitation_due_at.strftime("%B %d, %Y %I:%M %p")} GMT or if a new password reset is triggered.") |
49 | | - end |
50 | | - |
51 | | - it "has reset instructions" do |
52 | | - expect(mail.html_part.body).to match(%r{<p>If your invitation has an expired message, go <a href="http://.+?/users/password/new">here</a> and enter your email address to reset your password.</p>}) |
53 | | - expect(mail.html_part.body).to include("Feel free to ignore this email if you are not interested or if you feel it was sent by mistake.") |
54 | | - end |
55 | | - end |
56 | | - |
57 | | - context "when partner is re-invited" do |
58 | | - let(:invitation_sent_at) { Time.zone.now } |
59 | | - let(:user) { create(:partner_user, invitation_sent_at: invitation_sent_at) } |
60 | | - let(:role_name) { "partner" } |
61 | | - |
62 | | - it "invites to user" do |
63 | | - expect(mail.subject).to eq("You've been re-invited to be a #{role_name} in your Human Essentials App Account") |
64 | | - expect(mail.html_part.body).to include("You've been re-invited to become a <strong>#{role_name}</strong> in your Human Essentials App Account") |
65 | | - end |
66 | | - |
67 | | - it "has invite expiration message and reset instructions" do |
68 | | - expect(mail.html_part.body).to include("This invitation will expire at #{user.invitation_due_at.strftime("%B %d, %Y %I:%M %p")} GMT or if a new password reset is triggered.") |
69 | | - end |
70 | | - |
71 | | - it "has reset instructions" do |
72 | | - expect(mail.html_part.body).to match(%r{<p>If your invitation has an expired message, go <a href="http://.+?/users/password/new">here</a> and enter your email address to reset your password.</p>}) |
73 | | - expect(mail.html_part.body).to include("Feel free to ignore this email if you are not interested or if you feel it was sent by mistake.") |
74 | | - end |
75 | | - end |
76 | | - |
77 | | - context "when user is re-invited and has two roles" do |
78 | | - let(:invitation_sent_at) { Time.zone.now } |
79 | | - let(:user) { create(:partner_user, invitation_sent_at: invitation_sent_at) } |
80 | | - let(:role_name) { "org_user" } |
81 | | - let(:organization) { create(:organization) } |
82 | | - |
83 | | - it "invites to user" do |
84 | | - user.add_role(Role::ORG_USER, organization) |
85 | | - expect(mail.subject).to eq("You've been re-invited to be a #{role_name} in your Human Essentials App Account") |
86 | | - expect(mail.html_part.body).to include("You've been re-invited to become a <strong>#{role_name}</strong> in your Human Essentials App Account") |
87 | | - end |
88 | | - |
89 | | - it "has invite expiration message and reset instructions" do |
90 | | - expect(mail.html_part.body).to include("This invitation will expire at #{user.invitation_due_at.strftime("%B %d, %Y %I:%M %p")} GMT or if a new password reset is triggered.") |
91 | | - end |
92 | | - |
93 | | - it "has reset instructions" do |
94 | | - expect(mail.html_part.body).to match(%r{<p>If your invitation has an expired message, go <a href="http://.+?/users/password/new">here</a> and enter your email address to reset your password.</p>}) |
95 | | - expect(mail.html_part.body).to include("Feel free to ignore this email if you are not interested or if you feel it was sent by mistake.") |
96 | | - end |
97 | | - end |
98 | | - |
99 | | - context "when user is re-invited and has three roles" do |
100 | | - let(:invitation_sent_at) { Time.zone.now } |
101 | | - let(:user) { create(:partner_user, invitation_sent_at: invitation_sent_at) } |
102 | | - let(:role_name) { "org_admin" } |
103 | | - let(:organization) { create(:organization) } |
104 | | - |
105 | | - it "invites to user" do |
106 | | - user.add_role(Role::ORG_ADMIN, organization) |
107 | | - user.add_role(Role::ORG_USER, organization) |
108 | | - expect(mail.subject).to eq("You've been re-invited to be a #{role_name} in your Human Essentials App Account") |
109 | | - expect(mail.html_part.body).to include("You've been re-invited to become a <strong>#{role_name}</strong> in your Human Essentials App Account") |
110 | | - end |
111 | | - |
112 | | - it "has invite expiration message and reset instructions" do |
113 | | - expect(mail.html_part.body).to include("This invitation will expire at #{user.invitation_due_at.strftime("%B %d, %Y %I:%M %p")} GMT or if a new password reset is triggered.") |
114 | | - end |
115 | | - |
116 | | - it "has reset instructions" do |
117 | | - expect(mail.html_part.body).to match(%r{<p>If your invitation has an expired message, go <a href="http://.+?/users/password/new">here</a> and enter your email address to reset your password.</p>}) |
118 | | - expect(mail.html_part.body).to include("Feel free to ignore this email if you are not interested or if you feel it was sent by mistake.") |
| 42 | + expect(mail.subject).to eq("Your Human Essentials App Account Approval") |
| 43 | + 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!") |
119 | 44 | end |
120 | 45 | end |
121 | 46 | end |
|
0 commit comments