+ create_user_and_verify_setup_and_notifications true, 'active-notify-address@example.com', 'inactive-notify-address@example.com', nil, false
+ create_user_and_verify_setup_and_notifications true, 'active-notify-address@example.com', [], nil, false
+ create_user_and_verify_setup_and_notifications true, [], [], nil, false
+ create_user_and_verify_setup_and_notifications false, 'active-notify-address@example.com', 'inactive-notify-address@example.com', nil, false
+ create_user_and_verify_setup_and_notifications false, [], 'inactive-notify-address@example.com', nil, false
+ create_user_and_verify_setup_and_notifications false, [], [], nil, false
+ end
+
+ [
+ [false, 'active-notify@example.com', 'inactive-notify@example.com', 'inactive-none@example.com', false, false, true],
+ [false, 'active-notify@example.com', 'inactive-notify@example.com', 'inactive-vm@example.com', true, false, true],
+ [false, 'active-notify@example.com', 'inactive-notify@example.com', 'inactive-repo@example.com', false, true, true],
+ [false, 'active-notify@example.com', 'inactive-notify@example.com', 'inactive-both@example.com', true, true, true],
+
+ [false, [], [], 'inactive-none-no-notifications@example.com', false, false, true],
+ [false, [], [], 'inactive-vm-no-notifications@example.com', true, false, true],
+ [false, [], [], 'inactive-repo-no-notifications@example.com', false, true, true],
+ [false, [], [], 'inactive-both-no-notifications@example.com', true, true, true],
+
+ [true, 'active-notify@example.com', 'inactive-notify@example.com', 'active-none@example.com', false, false, true],
+ [true, 'active-notify@example.com', 'inactive-notify@example.com', 'active-vm@example.com', true, false, true],
+ [true, 'active-notify@example.com', 'inactive-notify@example.com', 'active-repo@example.com', false, true, true],
+ [true, 'active-notify@example.com', 'inactive-notify@example.com', 'active-both@example.com', true, true, true],
+
+ [true, [], [], 'active-none-no-notifications@example.com', false, false, true],
+ [true, [], [], 'active-vm-no-notifications@example.com', true, false, true],
+ [true, [], [], 'active-notify-no-notifications@example.com', 'inactive-repo@example.com', false, true, true],
+ [true, [], [], 'active-both-no-notifications@example.com', true, true, true],
+
+ [false, [], [], nil, true, true, false],
+ [false, [], [], 'arvados', true, true, false],
+ [false, [], [], '@example.com', true, true, false],
+ [false, [], [], '^^incorrect_format@example.com', true, true, false],
+
+# [false, 'active-notify@example.com', 'inactive-notify@example.com', 'repeat_username@example.com', true, true, true],
+# [false, 'active-notify@example.com', 'inactive-notify@example.com', 'repeat_username@example.com', true, false, true],
+# [false, 'active-notify@example.com', 'inactive-notify@example.com', 'with existing repo name', true, false, true],
+# [false, 'active-notify@example.com', 'inactive-notify@example.com', 'with existing vm login name', true, false, true],
+ ].each do |active, active_recipients, inactive_recipients, email, auto_setup_vm, auto_setup_repo, valid_email_format|
+ test "create new user with auto setup #{email} #{auto_setup_vm} #{auto_setup_repo}" do
+ auto_setup_new_users = Rails.configuration.auto_setup_new_users
+ auto_setup_new_users_with_vm_uuid = Rails.configuration.auto_setup_new_users_with_vm_uuid
+ auto_setup_new_users_with_repository = Rails.configuration.auto_setup_new_users_with_repository
+
+ begin
+ set_user_from_auth :admin
+
+ Rails.configuration.auto_setup_new_users = true
+
+ if auto_setup_vm
+ Rails.configuration.auto_setup_new_users_with_vm_uuid = virtual_machines(:testvm)['uuid']
+ else
+ Rails.configuration.auto_setup_new_users_with_vm_uuid = false
+ end
+
+ Rails.configuration.auto_setup_new_users_with_repository = auto_setup_repo
+
+ create_user_and_verify_setup_and_notifications active, active_recipients, inactive_recipients, email, valid_email_format
+ ensure
+ Rails.configuration.auto_setup_new_users = auto_setup_new_users
+ Rails.configuration.auto_setup_new_users_with_vm_uuid = auto_setup_new_users_with_vm_uuid
+ Rails.configuration.auto_setup_new_users_with_repository = auto_setup_new_users_with_repository
+ end
+ end