X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/872cf2e096a7b72722aa76040339a23e962cdf96..8917fa82999bdf0020f623db9869abae99930b56:/services/api/test/functional/arvados/v1/users_controller_test.rb diff --git a/services/api/test/functional/arvados/v1/users_controller_test.rb b/services/api/test/functional/arvados/v1/users_controller_test.rb index 28367831e1..1a8e94fcbe 100644 --- a/services/api/test/functional/arvados/v1/users_controller_test.rb +++ b/services/api/test/functional/arvados/v1/users_controller_test.rb @@ -734,6 +734,14 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase verify_link_existence response_user['uuid'], response_user['email'], false, false, false, false, false + + active_user = User.find_by_uuid(users(:active).uuid) + readable_groups = active_user.groups_i_can(:read) + all_users_group = Group.all.collect(&:uuid).select { |g| g.match /-f+$/ } + refute_includes(readable_groups, all_users_group, + "active user can read All Users group after being deactivated") + assert_equal(false, active_user.is_invited, + "active user is_invited after being deactivated & reloaded") end test "setup user with send notification param false and verify no email" do @@ -842,6 +850,71 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase check_active_users_index end + test "update active_no_prefs user profile and expect notification email" do + authorize_with :admin + + put :update, { + id: users(:active_no_prefs).uuid, + user: { + prefs: {:profile => {'organization' => 'example.com'}} + } + } + assert_response :success + + found_email = false + ActionMailer::Base.deliveries.andand.each do |email| + if email.subject == "Profile created by #{users(:active_no_prefs).email}" + found_email = true + break + end + end + assert_equal true, found_email, 'Expected email after creating profile' + end + + test "update active_no_prefs_profile user profile and expect notification email" do + authorize_with :admin + + user = {} + user[:prefs] = users(:active_no_prefs_profile).prefs + user[:prefs][:profile] = {:profile => {'organization' => 'example.com'}} + put :update, { + id: users(:active_no_prefs_profile).uuid, + user: user + } + assert_response :success + + found_email = false + ActionMailer::Base.deliveries.andand.each do |email| + if email.subject == "Profile created by #{users(:active_no_prefs_profile).email}" + found_email = true + break + end + end + assert_equal true, found_email, 'Expected email after creating profile' + end + + test "update active user profile and expect no notification email" do + authorize_with :admin + + put :update, { + id: users(:active).uuid, + user: { + prefs: {:profile => {'organization' => 'anotherexample.com'}} + } + } + assert_response :success + + found_email = false + ActionMailer::Base.deliveries.andand.each do |email| + if email.subject == "Profile created by #{users(:active).email}" + found_email = true + break + end + end + assert_equal false, found_email, 'Expected no email after updating profile' + end + + NON_ADMIN_USER_DATA = ["uuid", "kind", "is_active", "email", "first_name", "last_name"].sort