21059: Fix tests as "inactive user" email is now tied to is_invited
authorPeter Amstutz <peter.amstutz@curii.com>
Wed, 20 Dec 2023 17:47:46 +0000 (12:47 -0500)
committerPeter Amstutz <peter.amstutz@curii.com>
Wed, 20 Dec 2023 17:47:46 +0000 (12:47 -0500)
Also adjust the text of active/inactive user emails a bit.

Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

services/api/app/models/user.rb
services/api/app/views/admin_notifier/new_inactive_user.text.erb
services/api/app/views/admin_notifier/new_user.text.erb
services/api/test/unit/user_test.rb

index 7cc7cc491ca71d088d4fe64e436e54ac6eb375e2..4d7b2bbaeb2d7d42a79227cff1f2f09142f19179 100644 (file)
@@ -31,8 +31,8 @@ class User < ArvadosModel
   after_update :setup_on_activate
 
   before_create :check_auto_admin
-  before_create :set_initial_username, :if => Proc.new {
-    email
+  before_validation :set_initial_username, :if => Proc.new {
+    new_record? && email
   }
   before_create :active_is_not_nil
   after_create :after_ownership_change
index 4b572128b52500603b3a8e00a53d5e720025d25c..8a002fe172a839d5dde2f12a1a7ee536a414ac3c 100644 (file)
@@ -2,9 +2,11 @@
 
 SPDX-License-Identifier: AGPL-3.0 %>
 
-A new user landed on the inactive user page:
+A new user has been created, but not set up.
 
-  <%= @user.full_name %> <<%= @user.email %>>
+  <%= @user.full_name %> <<%= @user.email %>> (<%= @user.username %>)
+
+They will not be able to use Arvado unless set up by an admin.
 
 <% if Rails.configuration.Services.Workbench1.ExternalURL -%>
 Please see Workbench for more information:
index 75d2a28ce8d21d142b67739adbea61696da4d6b3..f62094b4eb8839ec6c6702c5349b1fad823831c5 100644 (file)
@@ -2,14 +2,11 @@
 
 SPDX-License-Identifier: AGPL-3.0 %>
 
-<%
-    add_to_message = @user.is_invited ? ' and setup' : ', but not setup'
-%>
-A new user has been created<%=add_to_message%>:
+A new user has been created and set up.
 
-  <%= @user.full_name %> <<%= @user.email %>>
+  <%= @user.full_name %> <<%= @user.email %>> (<%= @user.username %>)
 
-This user is <%= @user.is_active ? '' : 'NOT ' %>active.
+They are able to use Arvados.
 
 <% if Rails.configuration.Services.Workbench1.ExternalURL -%>
 Please see Workbench for more information:
index 97f096d29e65eba59ef12e295547490ff27362aa..810e5b45ecb2e77ad5394d20ffc807fb46d458ea 100644 (file)
@@ -347,10 +347,12 @@ class UserTest < ActiveSupport::TestCase
   test "create new user with notifications" do
     set_user_from_auth :admin
 
+    Rails.configuration.Users.AutoSetupNewUsers = false
+
     create_user_and_verify_setup_and_notifications true, active_notify_list, inactive_notify_list, nil, nil
     create_user_and_verify_setup_and_notifications true, active_notify_list, empty_notify_list, nil, nil
     create_user_and_verify_setup_and_notifications true, empty_notify_list, empty_notify_list, nil, nil
-    create_user_and_verify_setup_and_notifications false, active_notify_list, inactive_notify_list, nil, nil
+    create_user_and_verify_setup_and_notifications false, empty_notify_list, inactive_notify_list, nil, nil
     create_user_and_verify_setup_and_notifications false, empty_notify_list, inactive_notify_list, nil, nil
     create_user_and_verify_setup_and_notifications false, empty_notify_list, empty_notify_list, nil, nil
   end
@@ -379,13 +381,13 @@ class UserTest < ActiveSupport::TestCase
     [false, empty_notify_list, empty_notify_list, "arvados@example.com", false, false, "arvados2"],
     [true, active_notify_list, inactive_notify_list, "arvados@example.com", false, false, "arvados2"],
     [true, active_notify_list, inactive_notify_list, "root@example.com", true, false, "root2"],
-    [false, active_notify_list, inactive_notify_list, "root@example.com", true, false, "root2"],
+    [false, active_notify_list, empty_notify_list, "root@example.com", true, false, "root2"],
     [true, active_notify_list, inactive_notify_list, "roo_t@example.com", false, true, "root2"],
     [false, empty_notify_list, empty_notify_list, "^^incorrect_format@example.com", true, true, "incorrectformat"],
     [true, active_notify_list, inactive_notify_list, "&4a_d9.@example.com", true, true, "ad9"],
     [true, active_notify_list, inactive_notify_list, "&4a_d9.@example.com", false, false, "ad9"],
-    [false, active_notify_list, inactive_notify_list, "&4a_d9.@example.com", true, true, "ad9"],
-    [false, active_notify_list, inactive_notify_list, "&4a_d9.@example.com", false, false, "ad9"],
+    [false, active_notify_list, empty_notify_list, "&4a_d9.@example.com", true, true, "ad9"],
+    [false, active_notify_list, empty_notify_list, "&4a_d9.@example.com", false, false, "ad9"],
   ].each do |active, new_user_recipients, inactive_recipients, email, auto_setup_vm, auto_setup_repo, expect_username|
     test "create new user with auto setup active=#{active} email=#{email} vm=#{auto_setup_vm} repo=#{auto_setup_repo}" do
       set_user_from_auth :admin