Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ def account_activated(*params)
def confirm_account(*params)
receivers = params[0]
options = params[1]
@owner, @confirmation_url, @token_valid_to = options.values_at(:owner, :confirmation_url, :token_valid_to)
@owner, @confirmation_url = options.values_at(:owner, :confirmation_url)

minutes_valid_for = ENV['CONFIRMATION_TOKEN_VALID_FOR'].to_i
minutes_valid_for = 0 if minutes_valid_for.negative?
@token_valid_to = minutes_valid_for == 1 ? '1 minute' : "#{minutes_valid_for} minutes"
subject = 'Travis CI: Confirm your account.'
mail(from: from, to: to(receivers), subject: subject,
template_path: 'user_confirmation_mailer')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
</p>
<p><a id="account-activated-button" href="<%=@confirmation_url%>" target="_blank">Confirm your account</a></p>
<br/>
<p>Note: you must confirm your account in order to run builds on Travis CI. The confirmation link will expire after <br><%= @token_valid_to %></p>
<p>Note: you must confirm your account in order to run builds on Travis CI. The confirmation link will expire after <%= @token_valid_to %></p>
</td>
</tr>
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
end

describe '#confirm_account' do
before { ENV['CONFIRMATION_TOKEN_VALID_FOR'] = '60' }
let(:params) do
{
owner: { name: 'My Name' },
confirmation_url: 'https://confirm.me.plx',
token_valid_to: '2021-02-08 14:14:14'
token_valid_to: (Time.now.utc + 60 * 60).strftime('%Y-%m-%d %H:%M:%S')
}
end
subject(:mail) { described_class.confirm_account(recipients, **params) }

it 'contains the right data' do
expect(mail.to(recipients)).to eq(recipients)
expect(mail.from).to eq(['no-reply@travis-ci.com'])
Expand All @@ -37,7 +37,7 @@
expect(mail.body)
.to match('<p><a id="account-activated-button" href="https://confirm.me.plx" target="_blank">Confirm your account</a></p>')
expect(mail.body)
.to match('<p>Note: you must confirm your account in order to run builds on Travis CI. The confirmation link will expire after <br>2021-02-08 14:14:14</p>')
.to match('<p>Note: you must confirm your account in order to run builds on Travis CI. The confirmation link will expire after 60 minutes</p>')
end
end
end