add clear_caches method to user

test plan
 - specs should pass

Change-Id: Ib13398d368c81dd4d29e1245ed971fd2ef2b3fbf
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/249768
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Mysti Lilla <mysti@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
This commit is contained in:
Rob Orton 2020-10-09 17:29:15 -06:00
parent 2e96e905b2
commit e46881b63d
4 changed files with 8 additions and 6 deletions

View File

@ -1200,8 +1200,7 @@ class AccountsController < ApplicationController
pseudonym.update!(workflow_state: 'active')
pseudonym.clear_permissions_cache(user)
user.update_account_associations
user.clear_cache_key(*Canvas::CacheRegister::ALLOWED_TYPES['User'])
user.touch
user.clear_caches
render json: user || {}
end

View File

@ -2483,8 +2483,7 @@ class UsersController < ApplicationController
def clear_cache
user = api_find(User, params[:id])
if user && authorized_action(@domain_root_account, @current_user, :manage_site_settings)
user.clear_cache_key(*Canvas::CacheRegister::ALLOWED_TYPES['User'])
user.touch
user.clear_caches
render json: { status: "ok" }
end
end

View File

@ -1013,6 +1013,11 @@ class User < ActiveRecord::Base
deleted?
end
def clear_caches
self.clear_cache_key(*Canvas::CacheRegister::ALLOWED_TYPES['User'])
self.touch
end
alias_method :destroy_permanently!, :destroy
def destroy
self.remove_from_root_account(:all)

View File

@ -167,8 +167,7 @@ class UserMerge
end
from_user.reload
target_user.touch
target_user.clear_cache_key(*Canvas::CacheRegister::ALLOWED_TYPES['User'])
target_user.clear_caches
from_user.destroy
@merge_data.workflow_state = 'active'
@merge_data.save!