3604: Verify permission cache behavior in unsetup test
[arvados.git] / services / api / test / functional / arvados / v1 / users_controller_test.rb
index 299ae9e17f9d229f8117053a58f84c1966aca2f3..90399ca9ad601494ef8853e31d3e30ae7b49b916 100644 (file)
@@ -734,6 +734,9 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
 
     verify_link_existence response_user['uuid'], response_user['email'],
           false, false, false, false, false
+
+    assert_equal([], User.find_by_uuid(users(:active).uuid).groups_i_can(:read),
+                 "active user can still read some groups after being deactivated")
   end
 
   test "setup user with send notification param false and verify no email" do
@@ -842,20 +845,42 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     check_active_users_index
   end
 
-  test "update inactive user profile and expect notification email" do
+  test "update active_no_prefs user profile and expect notification email" do
     authorize_with :admin
 
     put :update, {
-      id: users(:inactive).uuid,
+      id: users(:active_no_prefs).uuid,
       user: {
-        prefs: {:profile => {'organization' => 'Curoverse'}}
+        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(:inactive).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
@@ -869,7 +894,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     put :update, {
       id: users(:active).uuid,
       user: {
-        prefs: {:profile => {'organization' => 'Curoverse'}}
+        prefs: {:profile => {'organization' => 'anotherexample.com'}}
       }
     }
     assert_response :success