1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
7 class UserNotifierTest < ActionMailer::TestCase
9 # Send the email, then test that it got queued
10 test "account is setup" do
13 Rails.configuration.Users.UserNotifierEmailBcc = ConfigLoader.to_OrderedOptions({"bcc-notify@example.com"=>{},"bcc-notify2@example.com"=>{}})
14 Rails.configuration.Users.UserSetupMailText = %{
15 <% if not @user.full_name.empty? -%>
16 <%= @user.full_name %>,
21 Your Arvados shell account has been set up. Please visit the virtual machines page <% if Rails.configuration.Services.Workbench1.ExternalURL %>at
23 <%= Rails.configuration.Services.Workbench1.ExternalURL %><%= "/" if !Rails.configuration.Services.Workbench1.ExternalURL.to_s.end_with?("/") %>users/<%= @user.uuid%>/virtual_machines <% else %><% end %>
25 for connection instructions.
31 email = UserNotifier.account_is_setup user
35 # Test the body of the sent email contains what we expect it to
36 assert_equal Rails.configuration.Users.UserNotifierEmailFrom, email.from.first
37 assert_equal Rails.configuration.Users.UserNotifierEmailBcc.stringify_keys.keys, email.bcc
38 assert_equal user.email, email.to.first
39 assert_equal 'Welcome to Arvados - account enabled', email.subject
40 assert (email.body.to_s.include? 'Your Arvados shell account has been set up'),
41 'Expected Your Arvados shell account has been set up in email body'
42 assert (email.body.to_s.include? Rails.configuration.Services.Workbench1.ExternalURL.to_s),
43 'Expected workbench url in email body'