|
15 | 15 | Cms::Mocks::EmailComponents::Text.generate_raw_data(
|
16 | 16 | text_content: [
|
17 | 17 | {
|
18 |
| - type: :paragraph, |
| 18 | + type: "paragraph", |
19 | 19 | children: [
|
20 |
| - {type: :text, text: "Hello {first_name}"} |
| 20 | + {type: "text", text: "Hello {first_name}"} |
21 | 21 | ]
|
22 | 22 | },
|
23 | 23 | {
|
24 |
| - type: :paragraph, |
| 24 | + type: "paragraph", |
25 | 25 | children: [
|
26 |
| - {type: :text, text: "You completed {last_cpd_title}"} |
| 26 | + {type: "text", text: "You completed {last_cpd_title}"} |
27 | 27 | ]
|
28 | 28 | },
|
29 | 29 | {
|
|
72 | 72 |
|
73 | 73 | describe "send_template" do
|
74 | 74 | before do
|
75 |
| - @mail = CmsMailer.with(user_id: user.id, template_slug: slug).send_template |
| 75 | + @mail = described_class.with(user_id: user.id, template_slug: slug).send_template |
76 | 76 | end
|
77 | 77 |
|
78 | 78 | it "renders the headers" do
|
|
131 | 131 | before do
|
132 | 132 | travel_to 1.day.from_now do
|
133 | 133 | create(:completed_achievement, activity: second_activity, user:)
|
134 |
| - @future_mail = CmsMailer.with(user_id: user.id, template_slug: slug).send_template |
| 134 | + @future_mail = described_class.with(user_id: user.id, template_slug: slug).send_template |
135 | 135 | end
|
136 | 136 | end
|
137 | 137 |
|
|
147 | 147 |
|
148 | 148 | describe "send_template with merged subject" do
|
149 | 149 | before do
|
150 |
| - @mail = CmsMailer.with(user_id: user.id, template_slug: slug_with_merge_subject).send_template |
| 150 | + @mail = described_class.with(user_id: user.id, template_slug: slug_with_merge_subject).send_template |
151 | 151 | end
|
152 | 152 |
|
153 | 153 | it "renders the headers" do
|
|
156 | 156 | expect(@mail.from).to eq(["[email protected]"])
|
157 | 157 | end
|
158 | 158 | end
|
| 159 | + |
| 160 | + describe "with missing template" do |
| 161 | + let(:missing_slug) { "missing_template_slug" } |
| 162 | + |
| 163 | + before do |
| 164 | + stub_strapi_email_template_missing(missing_slug) |
| 165 | + allow(Sentry).to receive(:capture_message) |
| 166 | + end |
| 167 | + |
| 168 | + it "logs error to sentry" do |
| 169 | + described_class.with(user_id: user.id, template_slug: missing_slug).send_template.deliver_now |
| 170 | + expect(Sentry) |
| 171 | + .to have_received(:capture_message) |
| 172 | + .with("Failed to load the email template #{missing_slug}") |
| 173 | + end |
| 174 | + end |
159 | 175 | end
|
0 commit comments