|
100 | 100 | let(:mail) { DistributionMailer.reminder_email(@distribution.id) }
|
101 | 101 |
|
102 | 102 | 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 |
104 | 104 | html = html_body(mail)
|
105 | 105 | expect(html).to match("This is a friendly reminder")
|
106 | 106 | expect(html).to match(%(For more information: <a href="mailto:[email protected]">[email protected]</a>))
|
|
109 | 109 | expect(mail.from).to eq(["[email protected]"])
|
110 | 110 | expect(mail.subject).to eq("PARTNER Distribution Reminder")
|
111 | 111 | 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 |
112 | 128 | end
|
113 | 129 |
|
114 | 130 | 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 | + |
116 | 145 | text = text_body(mail)
|
117 | 146 | expect(text).to match("This is a friendly reminder")
|
| 147 | + expect(text).to match("Custom reminder message example") |
118 | 148 | expect(text).to match(%(For more information: [email protected]))
|
119 | 149 | expect(mail.from).to eq(["[email protected]"])
|
120 | 150 | expect(mail.subject).to eq("PARTNER Distribution Reminder")
|
|
0 commit comments