Skip to content

Commit feba07d

Browse files
Release_2025.07.01
Release 2025 07 01
2 parents 7873877 + 8e24887 commit feba07d

File tree

4 files changed

+300
-1
lines changed

4 files changed

+300
-1
lines changed

lib/travis/addons/billing/mailer/billing_mailer.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ def subscription_cancellation_requested(receivers, subscription, owner, charge,
6060
mail(from: cancellation_email, to: receivers, subject: subject, template_path: 'billing_mailer')
6161
end
6262

63+
def csv_export_ready(receivers, subscription_or_report, owner, charge, event, report_or_other, cc_last_digits)
64+
@report = subscription_or_report
65+
@owner = owner
66+
subject = "Travis CI: Your #{@report[:type]&.capitalize} Report is Ready"
67+
68+
mail(from: travis_email, to: receivers, subject: subject, template_path: 'billing_mailer')
69+
end
70+
6371
private
6472

6573
def travis_email
Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
8+
<style type="text/css" media="screen">
9+
body {
10+
min-width: 100%;
11+
height: 100%;
12+
margin: 0;
13+
padding: 0;
14+
}
15+
16+
body, td {
17+
font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;
18+
}
19+
20+
strong {
21+
display: block;
22+
}
23+
24+
#travis-ci-email-container {
25+
height: 100%;
26+
width: 100%;
27+
padding: 30px;
28+
font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;
29+
text-align: center;
30+
color: #333333;
31+
line-height: 1.4;
32+
background-color: #f6f7fa;
33+
background-image: url('https://s3.amazonaws.com/travis-email-assets/billing-background.png');
34+
background-size: 600px 600px;
35+
}
36+
37+
#email-central-container {
38+
font-family: inherit;
39+
width: 500px;
40+
}
41+
42+
#email-content-container {
43+
padding: 6% 7% 5% 7%;
44+
background-color: #FFFFFF;
45+
text-align: center;
46+
width: 100%;
47+
}
48+
49+
50+
51+
#travis-logo-img-container {
52+
border-bottom: 2px solid #e5e7e9;
53+
padding-bottom: 4.545%;
54+
}
55+
56+
#travis-logo-img {
57+
width: 42%;
58+
}
59+
60+
#csv-ready-header {
61+
font-size: 24px;
62+
font-weight: 600;
63+
margin: 10.227% 0 6.818% 0;
64+
}
65+
66+
.green-highlight {
67+
color: #32d282;
68+
}
69+
70+
#closing-message-section {
71+
padding: 10.227% 0 1.136% 0;
72+
}
73+
74+
#closing-message-section > p {
75+
margin: 0;
76+
}
77+
78+
#travis-ci-twitter-section {
79+
text-align: center;
80+
}
81+
82+
#travis-ci-twitter-section a {
83+
display: inline-block;
84+
height: 32px;
85+
vertical-align: bottom;
86+
}
87+
88+
#travis-ci-twitter-section img {
89+
width: 32px;
90+
height: 32px;
91+
}
92+
93+
#travis-ci-email-footer-container {
94+
padding: 10% 7% 0% 7%;
95+
}
96+
97+
#questions-section {
98+
font-size: 18px;
99+
color: #0068FF;
100+
padding-bottom: 10.227%;
101+
}
102+
103+
#questions-section span {
104+
background-color: #f6f7fa;
105+
background-color: rgba(246, 247, 250, 0.8);
106+
}
107+
108+
#questions-section a {
109+
color: #0068FF;
110+
}
111+
112+
#travis-ci-footer-logo-section {
113+
padding-bottom: 6.818%;
114+
text-align: center;
115+
}
116+
117+
#email-footer-section {
118+
font-size: 11px;
119+
color: #9EA3A8;
120+
text-align: center;
121+
padding-top: 0px;
122+
margin: 0px;
123+
}
124+
125+
#email-footer-section a {
126+
color: #9ea3a8;
127+
}
128+
129+
#email-footer-section p {
130+
margin: 0px;
131+
}
132+
133+
#email-footer-section #payment-processor-message {
134+
margin-bottom: 3.409%;
135+
padding: 0 1%;
136+
}
137+
</style>
138+
</head>
139+
140+
<body style="min-width: 100%;height: 100%;margin: 0;padding: 0;font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;">
141+
142+
<table id="travis-ci-email-container" align="center" border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" style="height: 100%;width: 100%;padding: 30px;font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;text-align: center;color: #333333;line-height: 1.4;background-color: #f6f7fa;background-image: url(#{Travis.config.s3.url}/billing-background.png);background-size: 600px 600px;">
143+
<tr>
144+
<td align="center" valign="top" style="font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;">
145+
<table id="email-central-container" border="0" cellpadding="0" cellspacing="0" style="font-family: inherit;width: 500px;">
146+
<tr>
147+
<td style="font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;">
148+
<table id="email-content-container" border="0" cellpadding="0" cellspacing="0" style="padding: 6% 7% 5% 7%;background-color: #FFFFFF;text-align: center;width: 100%;">
149+
<tr>
150+
<td id="travis-logo-img-container" style="font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;border-bottom: 2px solid #e5e7e9;padding-bottom: 4.545%;">
151+
<img src="#{Travis.config.s3.url}/travis_ci_logo.png" alt="Travis CI Logo" id="travis-logo-img" style="width: 42%;">
152+
</td>
153+
</tr>
154+
<tr>
155+
<td style="font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;">
156+
<h2 id="charge-fail-header" style="font-size: 24px;font-weight: 600;margin: 10.227% 0 6.818% 0;">Your Report is Ready!</h2>
157+
</td>
158+
</tr>
159+
<tr>
160+
<td style="font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;">
161+
<p style="font-size: 16px;margin: 0 0 10px 0;">
162+
Hello,
163+
</p>
164+
165+
<p style="font-size: 16px;margin: 0 0 10px 0;">
166+
Your <%= @report && @report[:type] || 'CSV' %> report for
167+
<span class="green-highlight" style="color: #32d282;"><%= @owner && (@owner['login'] || @owner[:login]) || 'your account' %></span>
168+
is now ready for download.
169+
<% if @report && @report[:date_range] %>
170+
<p>This report contains data <%= @report[:date_range] %>.</p>
171+
<% end %>
172+
</p>
173+
174+
<p style="font-size: 16px;margin: 0 0 10px 0;">
175+
<% if @report && @report[:expires_at] %>
176+
This download link will expire on <%= Time.parse(@report[:expires_at]).strftime('%B %d, %Y at %H:%M %Z') rescue 'the expiration date' %>.
177+
<% else %>
178+
This download link will expire in 24 hours.
179+
<% end %>
180+
</p>
181+
182+
<a href="<%= @report && @report[:download_url] || '#' %>" class="button button--green" style="display: inline-block;padding: 12px 15px;color: #ffffff;background-color: #32d282;font-size: 14px;line-height: 14px;margin: 10px 0 10px 0;border-radius: 5px;text-decoration: none;text-transform: uppercase;font-weight: 600;">
183+
Download Report
184+
</a>
185+
</td>
186+
</tr>
187+
<tr>
188+
<td id="closing-message-section" align="center" valign="top" style="font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;padding: 10.227% 0 1.136% 0;">
189+
<p style="font-size: 16px;margin: 0;">Regards,</p>
190+
<p style="font-size: 16px;margin: 0;"><strong style="display: block;">The Travis CI Team</strong></p>
191+
</td>
192+
</tr>
193+
<tr>
194+
<td id="travis-ci-twitter-section" style="font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;text-align: center;">
195+
<a href="http://www.twitter.com/travisci" style="display: inline-block;height: 32px;vertical-align: bottom;">
196+
<img id="travis-ci-twitter-logo" src="#{Travis.config.s3.url}/twitter2x.png" alt="Twitter Logo" style="width: 32px;height: 32px;">
197+
</a>
198+
</td>
199+
</tr>
200+
</table>
201+
202+
<!-- Email Footer Section -->
203+
<table id="travis-ci-email-footer-container" border="0" cellpadding="0" cellspacing="0" style="padding: 10% 7% 0% 7%;">
204+
<tr>
205+
<td id="questions-section" align="center" valign="top" style="font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size: 18px;color: #0068FF;padding-bottom: 10.227%;">
206+
<span style="background-color: rgba(246, 247, 250, 0.8);">
207+
Have any questions?
208+
<a href="mailto:support@travis-ci.com" style="color: #0068FF;">We&rsquo;re here to help.</a>
209+
</span>
210+
</td>
211+
</tr>
212+
<tr>
213+
<td id="travis-ci-footer-logo-section" style="font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;padding-bottom: 6.818%;text-align: center;">
214+
<%= link_to(image_tag("#{Travis.config.s3.url}/TravisCI-Logo-BW.png", alt: 'black and white travis ci logo'), 'https://travis-ci.com')%>
215+
</td>
216+
</tr>
217+
<tr>
218+
<td id="email-footer-section" style="font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size: 11px;color: #9EA3A8;text-align: center;padding-top: 0px;margin: 0px;">
219+
<p style="margin: 0px;">
220+
Travis CI GmbH, Bonner Straße 12, 51379 Leverkusen, Germany | GF/CEO: Randy Jacops |
221+
<span>Contact: <%= link_to('contact@travis-ci.com', 'mailto:contact@travis-ci.com', style: 'color: #9EA3A8')%> | Amtsgericht Charlottenburg, Berlin, HRB 108397</span>
222+
</p>
223+
</td>
224+
</tr>
225+
</table>
226+
</td>
227+
</tr>
228+
</table>
229+
</td>
230+
</tr>
231+
</table>
232+
</body>
233+
</html>

lib/travis/addons/billing/task.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,23 @@ def cc_last_digits
3939
params[:cc_last_digits]
4040
end
4141

42+
def report
43+
params[:report]
44+
end
45+
4246
private
4347

4448
def send_email
45-
Mailer::BillingMailer.public_send(params[:email_type], recipients, subscription, owner, charge, event, invoice, cc_last_digits).deliver
49+
Mailer::BillingMailer.public_send(
50+
params[:email_type],
51+
recipients,
52+
params[:email_type] == 'csv_export_ready' ? report : subscription,
53+
owner,
54+
charge,
55+
event,
56+
invoice,
57+
cc_last_digits
58+
).deliver
4659
emails = recipients.map { |r| 'email=' + obfuscate_email_address(r) }.join(' ')
4760
info "type=#{type} status=sent msg='email sent #{emails}'"
4861
end

spec/addons/billing/mailer/billing_mailer_spec.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,4 +281,49 @@
281281

282282
end
283283
end
284+
285+
describe '#csv_export_ready' do
286+
subject(:mail) do
287+
described_class.csv_export_ready(
288+
[recipient],
289+
report,
290+
owner,
291+
charge,
292+
event,
293+
report_or_other = nil,
294+
options
295+
)
296+
end
297+
298+
let(:recipient) { 'nikola.granit@yahoo.com' }
299+
let(:owner) { { name: 'Ruby Monsters', login: 'rubymonsters', vcs_type: 'GithubUser', owner_type: 'User' } }
300+
let(:charge) { nil }
301+
let(:event) { nil }
302+
let(:report) { { type: 'usage', download_url: download_url, expires_at: (Time.now + 86400).iso8601 } }
303+
let(:download_url) { 'https://example.com/report.csv' }
304+
let(:options) { {} }
305+
306+
it 'is addressed to the user' do
307+
expect(mail.to).to eq([recipient])
308+
end
309+
310+
it 'comes from Travis' do
311+
expect(mail.from).to eq(['success@travis-ci.com'])
312+
end
313+
314+
it 'has the right subject' do
315+
expect(mail.subject).to eq('Travis CI: Your Usage Report is Ready')
316+
end
317+
318+
it 'contains the download link' do
319+
html = Capybara.string(mail.body.to_s)
320+
expect(html).to have_link('Download Report', href: download_url)
321+
end
322+
323+
it 'shows the report type' do
324+
html = Capybara.string(mail.body.to_s)
325+
expect(html).to have_text('Your usage report for')
326+
expect(html).to have_text('is now ready for download.')
327+
end
328+
end
284329
end

0 commit comments

Comments
 (0)