Skip to content

Commit 9c1bf18

Browse files
committed
Adds tests for distributions that include a custom reminder message.
1 parent 261b5ce commit 9c1bf18

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

spec/mailers/distribution_mailer_spec.rb

+32-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
let(:mail) { DistributionMailer.reminder_email(@distribution.id) }
101101

102102
context 'HTML format' do
103-
it "renders the body with organization's email text" do
103+
it "renders the body with organization's email text without a custom_reminder message" do
104104
html = html_body(mail)
105105
expect(html).to match("This is a friendly reminder")
106106
expect(html).to match(%(For more information: <a href="mailto:[email protected]">[email protected]</a>))
@@ -109,12 +109,42 @@
109109
expect(mail.from).to eq(["[email protected]"])
110110
expect(mail.subject).to eq("PARTNER Distribution Reminder")
111111
end
112+
113+
it "renders the body with organization's email text with a custom_reminder message" do
114+
custom_reminder = "Custom reminder message example \n\n%{delivery_method} %{distribution_date}\n\n%{partner_name}\n\n%{comment}"
115+
@distribution.update!({custom_reminder: custom_reminder})
116+
117+
mail = DistributionMailer.reminder_email(@distribution.id)
118+
119+
html = html_body(mail)
120+
expect(html).to match("This is a friendly reminder")
121+
expect(html).to match("Custom reminder message example")
122+
expect(html).to match(%(For more information: <a href="mailto:[email protected]">[email protected]</a>))
123+
expect(mail.to).to eq([@distribution.request.user_email])
124+
expect(mail.cc).to eq([@distribution.partner.email])
125+
expect(mail.from).to eq(["[email protected]"])
126+
expect(mail.subject).to eq("PARTNER Distribution Reminder")
127+
end
112128
end
113129

114130
context 'Text format' do
115-
it "renders the body with organization's email text" do
131+
it "renders the body with organization's email text without a custom_reminder message" do
132+
text = text_body(mail)
133+
expect(text).to match("This is a friendly reminder")
134+
expect(text).to match(%(For more information: [email protected]))
135+
expect(mail.from).to eq(["[email protected]"])
136+
expect(mail.subject).to eq("PARTNER Distribution Reminder")
137+
end
138+
139+
it "renders the body with organization's email text with a custom_reminder message" do
140+
custom_reminder = "Custom reminder message example \n\n%{delivery_method} %{distribution_date}\n\n%{partner_name}\n\n%{comment}"
141+
@distribution.update!({custom_reminder: custom_reminder})
142+
143+
mail = DistributionMailer.reminder_email(@distribution.id)
144+
116145
text = text_body(mail)
117146
expect(text).to match("This is a friendly reminder")
147+
expect(text).to match("Custom reminder message example")
118148
expect(text).to match(%(For more information: [email protected]))
119149
expect(mail.from).to eq(["[email protected]"])
120150
expect(mail.subject).to eq("PARTNER Distribution Reminder")

0 commit comments

Comments
 (0)